Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ownership mine filter #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion appintheair_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,28 @@ def main():
type=str,
help="File name used for outputted csv. Should include .csv extension"
)
parser.add_argument(
'-m',
'--mine',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are your thoughts on making this argument --ownership?

I am thinking that then a user can pass nargs of strings (MINE, NOT_MINE, UNKNOWN) and the script will include any matching trips if the Ownership matches.

action='store_true',
help="Exclude flights that are set as other people's"
)
args = parser.parse_args()
additional_fields = args.additional_fields
only_mine = args.mine

with open('data.txt', 'r') as file:
finput = [line.rstrip() for line in file]

flights = []
parse_next = False
my_flight = False
for i in range(len(finput)):
if parse_next == True:
if finput[i].split(":")[0] != "hotels":
if only_mine and not my_flight:
parse_next = False
continue
flight_objects = finput[i].split(";")
data = parse_flight_data(flight_objects, additional_fields)
flights.append(data)
Expand All @@ -131,6 +142,11 @@ def main():
elif finput[i].split(":")[0] == "flights":
parse_next = True
continue
elif finput[i].split(";")[0].startswith("Ownership."):
if finput[i].split(";")[0].split(".")[1] == "MINE":
my_flight = True
else:
my_flight = False

logging.info(f"{str(len(flights))} flights found")

Expand All @@ -147,4 +163,4 @@ def main():
logging.info(f"Data successfully saved in output.csv")

if __name__ == "__main__":
main()
main()