text stringlengths 1 93.6k |
|---|
parser_cmd.add_argument('vendor', type=int, help="vendor number of the report to download (for a list of your vendor numbers, use the 'getVendors' command)")
|
parser_cmd.add_argument('date', help="specific day covered by the report (use YYYYMMDD format)")
|
parser_cmd.add_argument('-v', '--version', choices=['1_0', '1_1', '1_2', '1_3'], default='1_3', help="report format version to use (if omitted, the latest available version is used)")
|
parser_cmd.set_defaults(func=itc_get_subscriber_report)
|
parser_cmd = subparsers.add_parser('getNewsstandReport', help="download a magazines & newspapers report file for a specific date range", parents=[parser_auth_token])
|
parser_cmd.add_argument('vendor', type=int, help="vendor number of the report to download (for a list of your vendor numbers, use the 'getVendors' command)")
|
parser_cmd.add_argument('datetype', choices=['Daily', 'Weekly'], help="length of time covered by the report")
|
parser_cmd.add_argument('date', help="specific time covered by the report (weekly reports, like daily reports, use YYYYMMDD, where the day used is the Sunday that week ends")
|
parser_cmd.set_defaults(func=itc_get_newsstand_report)
|
parser_cmd = subparsers.add_parser('getOptInReport', help="download contact information for customers who opt in to share their contact information with you", parents=[parser_auth_token])
|
parser_cmd.add_argument('vendor', type=int, help="vendor number of the report to download (for a list of your vendor numbers, use the 'getVendors' command)")
|
parser_cmd.add_argument('date', help="specific day covered by the report (use YYYYMMDD format)")
|
parser_cmd.set_defaults(func=itc_get_opt_in_report)
|
parser_cmd = subparsers.add_parser('getPreOrderReport', help="download a summary report file of pre-ordered items for a specific date range", parents=[parser_auth_token])
|
parser_cmd.add_argument('vendor', type=int, help="vendor number of the report to download (for a list of your vendor numbers, use the 'getVendors' command)")
|
parser_cmd.add_argument('datetype', choices=['Daily', 'Weekly', 'Monthly', 'Yearly'], help="length of time covered by the report")
|
parser_cmd.add_argument('date', help="specific time covered by the report (weekly reports use YYYYMMDD, where the day used is the Sunday that week ends; monthly reports use YYYYMM; yearly reports use YYYY)")
|
parser_cmd.set_defaults(func=itc_get_pre_order_report)
|
parser_cmd = subparsers.add_parser('getPodcastsSubscriptionSnapshotReport', help="download an aggregated Apple Podcasts Subscription Snapshot report file for a specific day", parents=[parser_auth_token])
|
parser_cmd.add_argument('vendor', type=int, help="vendor number of the report to download (for a list of your vendor numbers, use the 'getVendors' command)")
|
parser_cmd.add_argument('date', help="specific day covered by the report (use YYYYMMDD format)")
|
parser_cmd.set_defaults(func=itc_get_podcasts_subscription_snapshot_report)
|
parser_cmd = subparsers.add_parser('generateToken', help="generate a token for accessing App Store Connect (expires after 180 days) and optionally store it in the macOS Keychain", parents=[parser_auth_password])
|
parser_cmd.add_argument('--update-keychain-item', metavar="KEYCHAIN_ITEM", help='name of the macOS Keychain item in which the new access token should be stored in')
|
parser_cmd.set_defaults(func=itc_generate_token)
|
parser_cmd = subparsers.add_parser('viewToken', help="display current App Store Connect access token and its expiration date", parents=[parser_auth_password])
|
parser_cmd.set_defaults(func=itc_view_token)
|
parser_cmd = subparsers.add_parser('deleteToken', help="delete an existing App Store Connect access token", parents=[parser_auth_password])
|
parser_cmd.set_defaults(func=itc_delete_token)
|
args = parser_main.parse_args()
|
try:
|
validate_arguments(args)
|
except ValueError as e:
|
parser_main.error(e)
|
return args
|
def validate_arguments(args):
|
"""Do some additional checks on the passed arguments which argparse couldn't handle directly"""
|
if sys.platform != 'darwin' and (args.password_keychain_item or args.access_token_keychain_item):
|
raise ValueError("Error: Keychain support is limited to macOS")
|
if args.access_token_keychain_item:
|
try:
|
keychain.find_generic_password(None, args.access_token_keychain_item, '')
|
except:
|
raise ValueError("Error: Could not find an item named '{0}' in the default Keychain".format(args.access_token_keychain_item))
|
if args.password_keychain_item:
|
try:
|
keychain.find_generic_password(None, args.password_keychain_item, '')
|
except:
|
raise ValueError("Error: Could not find an item named '{0}' in the default Keychain".format(args.password_keychain_item))
|
if not args.account and (args.command == 'getVendorsAndRegions' or args.command == 'getVendors' or args.command == 'getFinancialReport'):
|
raise ValueError("Error: Argument -a/--account is needed for command '%s'" % args.command)
|
if hasattr(args, 'fiscalyear'):
|
try:
|
datetime.datetime.strptime(args.fiscalyear, "%Y")
|
except:
|
raise ValueError("Error: Fiscal year must be specified as YYYY")
|
if hasattr(args, 'fiscalperiod'):
|
try:
|
if int(args.fiscalperiod) < 1 or int(args.fiscalperiod) > 12:
|
raise Exception
|
except:
|
raise ValueError("Error: Fiscal period must be a value between 1 and 12")
|
if hasattr(args, 'datetype'):
|
format = '%Y%m%d'
|
error = "Date must be specified as YYYYMMDD for daily reports"
|
if args.datetype == 'Weekly':
|
error = "Date must be specified as YYYYMMDD for weekly reports, where the day used is the Sunday that week ends"
|
if args.datetype == 'Monthly':
|
error = "Date must be specified as YYYYMM for monthly reports"
|
format = '%Y%m'
|
if args.datetype == 'Yearly':
|
error = "Date must be specified as YYYY for yearly reports"
|
format = '%Y'
|
try:
|
datetime.datetime.strptime(args.date, format)
|
except:
|
raise ValueError("Error: " + error)
|
# main
|
if __name__ == '__main__':
|
args = parse_arguments()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.