GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (284)

taskjuggler_python/tjpy_client.py (37 issues)

1
"""A sample CLI with API interaction."""
2
3
import logging
4
5
from getpass import getpass
0 ignored issues
show
Unused getpass imported from getpass
Loading history...
6
import argparse, sys, datetime
0 ignored issues
show
Multiple imports on one line (argparse, sys, datetime)
Loading history...
The import sys seems to be unused.
Loading history...
7
from jsonjuggler import *
0 ignored issues
show
Unable to import 'jsonjuggler'
Loading history...
The usage of wildcard imports like jsonjuggler should generally be avoided.
Loading history...
8
import juggler
9
10
import dateutil.parser
0 ignored issues
show
third party import "import dateutil.parser" should be placed before "from jsonjuggler import *"
Loading history...
11
12
from airtable import Airtable
0 ignored issues
show
third party import "from airtable import Airtable" should be placed before "from jsonjuggler import *"
Loading history...
13
14
DEFAULT_LOGLEVEL = 'warning'
15
# DEFAULT_OUTPUT = 'export.tjp'
16
log = logging.getLogger(__name__)
17
18
def main():
19
    logging.basicConfig(level=logging.WARN)
20
21
    ARGPARSER = argparse.ArgumentParser()
22
    ARGPARSER.add_argument('-l', '--loglevel', dest='loglevel', default=DEFAULT_LOGLEVEL,
23
                          action='store', required=False, choices=["debug", "info", "warn", "error"],
0 ignored issues
show
Wrong continued indentation (add 1 space).
Loading history...
This line is too long as per the coding-style (101/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
24
                          help='Level for logging (strings from logging python package: "warn", "info", "debug")')
0 ignored issues
show
Wrong continued indentation (add 1 space).
Loading history...
This line is too long as per the coding-style (114/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
25
    ARGPARSER.add_argument('-a', '--api', dest='api', default=None,
26
                          action='store', required=True, choices=['airtable'],
0 ignored issues
show
Wrong continued indentation (add 1 space).
Loading history...
27
                          help='Execute specified API: only "airtable" is currently supported')
0 ignored issues
show
Wrong continued indentation (add 1 space).
Loading history...
28
    ARGPARSER.add_argument('-k', '--api-key', dest='apikey', default="",
29
                          action='store', required=True,
0 ignored issues
show
Wrong continued indentation (add 1 space).
Loading history...
30
                          help='Specify API key where appropriate (e.g. -k keyAnIuYcufa3dD)')
0 ignored issues
show
Wrong continued indentation (add 1 space).
Loading history...
31
    ARGPARSER.add_argument('-b', '--base', dest='base', default="",
32
                          action='store', required=True,
0 ignored issues
show
Wrong continued indentation (add 1 space).
Loading history...
33
                          help='Specify Base ID where appropriate (e.g. -b appA8ZuLosBV4GDSd)')
0 ignored issues
show
Wrong continued indentation (add 1 space).
Loading history...
34
    ARGPARSER.add_argument('-t', '--table', dest='table', default="",
35
                          action='store', required=True,
0 ignored issues
show
Wrong continued indentation (add 1 space).
Loading history...
36
                          help='Specify Table ID where appropriate (e.g. -t Tasks)')
0 ignored issues
show
Wrong continued indentation (add 1 space).
Loading history...
37
    ARGPARSER.add_argument('-v', '--view', dest='view', default="",
38
                          action='store', required=True,
0 ignored issues
show
Wrong continued indentation (add 1 space).
Loading history...
39
                          help='Specify Table View where appropriate (e.g. -v Work)')
0 ignored issues
show
Wrong continued indentation (add 1 space).
Loading history...
40
    ARGPARSER.add_argument('--dry-run', dest='dryrun', default=False,
41
                          action='store_true', required=False,
0 ignored issues
show
Wrong continued indentation (add 1 space).
Loading history...
42
                          help='Do not commit calculation results')
0 ignored issues
show
Wrong continued indentation (add 1 space).
Loading history...
43
    # ARGPARSER.add_argument('-o', '--output', dest='output', default=DEFAULT_OUTPUT,
44
    #                       action='store', required=False,
45
    #                       help='Output .tjp file for task-juggler')
46
    ARGS = ARGPARSER.parse_args()
47
48
    set_logging_level(ARGS.loglevel)
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'set_logging_level'
Loading history...
49
50
    # PASSWORD = getpass('Enter generic password for {user}: '.format(user=ARGS.username))
51
    
0 ignored issues
show
Trailing whitespace
Loading history...
52
    airtable = Airtable(ARGS.base, ARGS.table, api_key=ARGS.apikey)
53
    
0 ignored issues
show
Trailing whitespace
Loading history...
54
    data = [x["fields"] for x in airtable.get_all(view=ARGS.view)] 
0 ignored issues
show
Trailing whitespace
Loading history...
55
    for rec in data:
56
        preference = 0
57
        if "preference" in rec:
58
            preference = int(rec['preference'])
59
        if "priority" in rec:
60
            if rec["priority"].lower() == "low":
61
                pri = preference + 100
62
            elif rec["priority"].lower() == "high":
63
                pri = preference + 200
64
            elif rec["priority"].lower() == "critical":
65
                pri = preference + 300
66
            else:
67
                pri = 1
68
        else:
69
            pri = preference + 100 # low
70
        rec["priority"] = pri
71
        if 'appointment' in rec:
72
            rec['start'] = rec['appointment']
73
            del rec["priority"] # tasks scheduling is not guaranteed if priority is set
74
        if 'depends' in rec:
75
            rec['depends'] = [int(x) for x in re.findall(r"[\w']+", rec["depends"])]
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 're'
Loading history...
76
        if "priority" in rec and  "deadline" in rec and not rec["priority"] >= 300:
77
            diff_days = (datetime.datetime.now() - dateutil.parser.parse(rec["deadline"])).days
78
            if diff_days < 0: diff_days = 0
0 ignored issues
show
More than one statement on a single line
Loading history...
79
            rec["priority"] = rec["priority"] + diff_days * 3
80
            if rec["priority"] >= 250: rec["priority"] = 250
0 ignored issues
show
More than one statement on a single line
Loading history...
81
    
0 ignored issues
show
Trailing whitespace
Loading history...
82
    JUGGLER = DictJuggler(data)
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'DictJuggler'
Loading history...
83
    JUGGLER.run()
84
    
0 ignored issues
show
Trailing whitespace
Loading history...
85
    if ARGS.dryrun: return
0 ignored issues
show
More than one statement on a single line
Loading history...
86
    
0 ignored issues
show
Trailing whitespace
Loading history...
87
    for t in JUGGLER.walk(juggler.JugglerTask):
88
        airtable.update_by_field("id", t.get_id(), {"booking": t.walk(juggler.JugglerBooking)[0].decode()[0].isoformat()})
0 ignored issues
show
This line is too long as per the coding-style (122/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
89
    
0 ignored issues
show
Trailing whitespace
Loading history...
90
if __name__ == '__main__':  # pragma: no cover
91
    main()
92