Skip to content

Commit

Permalink
Cleaned input args
Browse files Browse the repository at this point in the history
  • Loading branch information
Sieboldianus committed Dec 3, 2018
1 parent 8c7a407 commit 4730eb7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pip install lbsntransform
e.g. with the following command line args

```shell
lbsntransform.exe --LocalInput 1 --LocalFileType '*.json' --transferlimit 1000 --CSVOutput
lbsntransform.exe --Origin 3 --LocalInput 1 --LocalFileType '*.json' --transferlimit 1000 --CSVOutput
```

.. the the tool will:
Expand Down Expand Up @@ -59,9 +59,9 @@ Python's site-packages folder with:
python setup.py develop
```

Now you can run tool in your shell with:
Now you can run tool in your shell with (Origin 3 = Twitter):
```shell
lbsntransform --LocalInput 1 --LocalFileType '*.json' --transferlimit 1000 --CSVOutput
lbsntransform --Origin 3 --LocalInput 1 --LocalFileType '*.json' --transferlimit 1000 --CSVOutput
```

..or import the package to other python projects with:
Expand Down
25 changes: 10 additions & 15 deletions lbsntransform/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def __init__(self):
## Set Default Config options here
## or define options as input args
self.Origin = 3 # Defaults to 3: Twitter (1 - Instagram, 2 - Flickr, 3 - Twitter)
self.LocalInput = 0 # Read from File/CSV
self.LocalInput = False # Read from File/CSV
self.LocalFileType = '*.json' # If localread, specify filetype (*.json, *.csv etc.)
self.InputPath = None # optionally provide path to input folder, otherwise ./Input/ will be used
self.is_stacked_json = 0
self.is_stacked_json = False
self.dbUser_Input = 'example-user-name'
self.dbPassword_Input = 'example-user-password'
self.dbServeradressInput = '222.22.222.22'
Expand All @@ -24,7 +24,8 @@ def __init__(self):
self.transferCount = 50000 #default:50k # after how many parsed records should the result be transferred to the DB. Larger values improve speed, because duplicate check happens in Python and not in Postgres Coalesce; larger values are heavier on memory.
self.number_of_records_to_fetch = 10000
self.transferReactions = 1
self.disableReactionPostReferencing = None # 0 = Save Original Tweets of Retweets in "posts"; 1 = do not store Original Tweets of Retweets; !Not implemented: 2 = Store Original Tweets of Retweets as "post_reactions"
# Enable this option in args to prevent empty posts stored due to Foreign Key Exists Requirement
self.disableReactionPostReferencing = False # 0 = Save Original Tweets of Retweets in "posts"; 1 = do not store Original Tweets of Retweets; !Not implemented: 2 = Store Original Tweets of Retweets as "post_reactions"
self.transferNotGeotagged = 1
self.startWithdb_row_number = 0
self.end_with_db_row_number = None
Expand All @@ -38,10 +39,10 @@ def __init__(self):
def parseArgs(self):
parser = argparse.ArgumentParser()
parser.add_argument('-sO', "--Origin", default=self.Origin)
parser.add_argument('-lI', "--LocalInput", default=self.LocalInput)
parser.add_argument('-lI', "--LocalInput", action='store_true', default=False)
parser.add_argument('-lT', "--LocalFileType", default=self.LocalFileType)
parser.add_argument('-iP', "--InputPath", default=self.LocalFileType)
parser.add_argument('-iS', "--isStackedJson", default=self.is_stacked_json)
parser.add_argument('-iS', "--isStackedJson", action='store_true', default=False)
parser.add_argument('-pO', "--dbPassword_Output", default=self.dbPassword_Output)
parser.add_argument('-uO', "--dbUser_Output", default=self.dbUser_Output)
parser.add_argument('-aO', "--dbServeradressOutput", default=self.dbServeradressOutput)
Expand All @@ -54,7 +55,7 @@ def parseArgs(self):
parser.add_argument('-tC', "--transferCount", default=self.transferCount)
parser.add_argument('-nR', "--numberOfRecordsToFetch", default=self.number_of_records_to_fetch)
parser.add_argument('-tR', "--transferReactions", default=self.transferReactions)
parser.add_argument('-rR', "--disableReactionPostReferencing", default=self.disableReactionPostReferencing)
parser.add_argument('-rR', "--disableReactionPostReferencing", action='store_true', default=False)
parser.add_argument('-tG', "--transferNotGeotagged", default=self.transferNotGeotagged)
parser.add_argument('-rS', "--startWithDBRowNumber", default=self.startWithdb_row_number)
parser.add_argument('-rE', "--endWithDBRowNumber", default=self.end_with_db_row_number)
Expand All @@ -66,14 +67,11 @@ def parseArgs(self):
parser.add_argument('-CSVal', "--CSVallowLinebreaks", action='store_true', default=False)

args = parser.parse_args()
if args.LocalInput and int(args.LocalInput) == 1:
if args.LocalInput:
self.LocalInput = True
self.LocalFileType = args.LocalFileType
if args.isStackedJson:
if int(args.isStackedJson) == 1:
self.is_stacked_json = True
else:
self.is_stacked_json = False
self.is_stacked_json = True
if not self.InputPath:
self.InputPath = f'{os.getcwd()}\\01_Input\\'
print(f'Using Path: {self.InputPath}')
Expand Down Expand Up @@ -102,11 +100,8 @@ def parseArgs(self):
if args.numberOfRecordsToFetch:
self.number_of_records_to_fetch = int(args.numberOfRecordsToFetch)
self.transferReactions = args.transferReactions
if args.disableReactionPostReferencing and int(args.disableReactionPostReferencing) == 1:
# Enable this option in args to prevent empty posts stored due to Foreign Key Exists Requirement
if args.disableReactionPostReferencing:
self.disableReactionPostReferencing = True
else:
self.disableReactionPostReferencing = False
self.transferNotGeotagged = args.transferNotGeotagged
if args.startWithDBRowNumber:
self.startWithdb_row_number = int(args.startWithDBRowNumber)
Expand Down

0 comments on commit 4730eb7

Please sign in to comment.