mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Optimize imports, indent with 4 spaces (PEP8)
This commit is contained in:
parent
fdd40c484a
commit
6272f1ad5d
1 changed files with 71 additions and 63 deletions
|
@ -25,7 +25,14 @@
|
||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
import os, sys, re, time, datetime, json, argparse
|
import argparse
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
|
||||||
if sys.version_info >= (3, 0):
|
if sys.version_info >= (3, 0):
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
@ -33,6 +40,7 @@ if sys.version_info >= (3,0):
|
||||||
else:
|
else:
|
||||||
from urllib2 import urlopen, HTTPError
|
from urllib2 import urlopen, HTTPError
|
||||||
|
|
||||||
|
|
||||||
def enumerate(path):
|
def enumerate(path):
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
raise Exception("Directory '%s' does not exist" % path)
|
raise Exception("Directory '%s' does not exist" % path)
|
||||||
|
@ -48,7 +56,7 @@ def holidata(locale, year):
|
||||||
|
|
||||||
|
|
||||||
def update_locales(locales, regions, years):
|
def update_locales(locales, regions, years):
|
||||||
if years == []:
|
if not years:
|
||||||
years = [datetime.datetime.now().year, datetime.datetime.now().year + 1]
|
years = [datetime.datetime.now().year, datetime.datetime.now().year + 1]
|
||||||
|
|
||||||
for locale in locales:
|
for locale in locales:
|
||||||
|
@ -102,7 +110,8 @@ def main(args):
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
usage = """See http://holidata.net for details of supported locales and regions."""
|
usage = """See http://holidata.net for details of supported locales and regions."""
|
||||||
parser = argparse.ArgumentParser(description="Update holiday data files. Simply run 'refresh' to update all of them.")
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Update holiday data files. Simply run 'refresh' to update all of them.")
|
||||||
parser.add_argument('--locale', nargs='+', help='Specific locale to update.')
|
parser.add_argument('--locale', nargs='+', help='Specific locale to update.')
|
||||||
parser.add_argument('--region', nargs='+', help='Specific locale region to update.')
|
parser.add_argument('--region', nargs='+', help='Specific locale region to update.')
|
||||||
parser.add_argument('--year', nargs='+', help='Specific year to fetch.', type=int, default=[])
|
parser.add_argument('--year', nargs='+', help='Specific year to fetch.', type=int, default=[])
|
||||||
|
@ -112,4 +121,3 @@ if __name__ == "__main__":
|
||||||
main(args)
|
main(args)
|
||||||
except Exception as msg:
|
except Exception as msg:
|
||||||
print('Error:', msg)
|
print('Error:', msg)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue