Clean lint problems
This commit is contained in:
@@ -1,13 +1,8 @@
|
||||
import sqlite3
|
||||
import os
|
||||
import argparse
|
||||
import json
|
||||
import getpass
|
||||
import datetime
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
import sys
|
||||
|
||||
|
||||
class TypeAction(Enum):
|
||||
@@ -31,7 +26,7 @@ class Action:
|
||||
return str(self.__dict__)
|
||||
|
||||
|
||||
def handle_action(args, last_action, conn):
|
||||
def handle_action(_1, _2, conn):
|
||||
logging.info(">> handle action")
|
||||
query = "SELECT * FROM action;"
|
||||
cursor = conn.cursor()
|
||||
|
||||
4
args.py
4
args.py
@@ -30,9 +30,9 @@ def arg_string(arg, required=""):
|
||||
return arg.strip()
|
||||
|
||||
|
||||
def arg_number(arg, required=""):
|
||||
def arg_number(arg): # , required=""):
|
||||
if not arg.isdigit():
|
||||
print("Invalid value") # TODO
|
||||
print("Invalid value")
|
||||
sys.exit(1)
|
||||
|
||||
return int(arg)
|
||||
|
||||
7
note.py
7
note.py
@@ -1,15 +1,10 @@
|
||||
# import sqlite3
|
||||
import os
|
||||
import argparse
|
||||
import json
|
||||
import getpass
|
||||
import datetime
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from action import record_action
|
||||
from action import TypeAction
|
||||
import project
|
||||
|
||||
from args import get_string_arg
|
||||
from args import arg_number
|
||||
@@ -22,7 +17,7 @@ class Note:
|
||||
|
||||
def handle_note(args, last_action, conn):
|
||||
logging.info("> handle note")
|
||||
logging.debug("args: " + str(args))
|
||||
logging.debug("args: %s", args)
|
||||
|
||||
if not args:
|
||||
list_note(
|
||||
|
||||
16
phelp.py
16
phelp.py
@@ -28,12 +28,8 @@ def handle_help(args, *_):
|
||||
sys.exit(1)
|
||||
|
||||
if candidate < 0:
|
||||
print(
|
||||
"Invalid command ({}), run '{} help' for help".format(
|
||||
args[0], os.path.basename(__file__)
|
||||
)
|
||||
)
|
||||
sys.exit(1)
|
||||
print("No help, <{}> is unknown command".format(args[0]))
|
||||
help_help()
|
||||
|
||||
cmd_handler[candidate][1]()
|
||||
|
||||
@@ -88,6 +84,7 @@ Examples:
|
||||
* 1: (username) [current] Task and Bugs (0 tasks)
|
||||
"""
|
||||
)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def help_task():
|
||||
@@ -154,6 +151,7 @@ Examples:
|
||||
1: (username) [done] [normal] Oct 10, 2010 4:30 Hack this (0 notes)
|
||||
"""
|
||||
)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def help_note():
|
||||
@@ -177,6 +175,7 @@ Listing notes:
|
||||
$ pits note
|
||||
"""
|
||||
)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def help_action():
|
||||
@@ -186,6 +185,7 @@ def help_action():
|
||||
pits log
|
||||
"""
|
||||
)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def help_info():
|
||||
@@ -195,6 +195,7 @@ def help_info():
|
||||
pits info
|
||||
"""
|
||||
)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def help_help():
|
||||
@@ -216,10 +217,12 @@ All commands might be shortened as long as they remain unambiguous. See 'pits he
|
||||
information on a specific command.
|
||||
"""
|
||||
)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def help_version():
|
||||
print("todo")
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def help_init():
|
||||
@@ -238,3 +241,4 @@ Example:
|
||||
Created database /home/user/.pit
|
||||
"""
|
||||
)
|
||||
sys.exit(0)
|
||||
|
||||
11
pits.py
11
pits.py
@@ -1,9 +1,6 @@
|
||||
import sqlite3
|
||||
import os
|
||||
import argparse
|
||||
import json
|
||||
import getpass
|
||||
import datetime
|
||||
import logging
|
||||
import sys
|
||||
|
||||
@@ -18,7 +15,7 @@ import utils
|
||||
# logging.basicConfig(level=logging.ERROR, format='%(levelname)7s :: %(message)s')
|
||||
# logging.basicConfig(level=logging.DEBUG, format='%(asctime)s :: %(levelname)s :: %(message)s')
|
||||
logging.basicConfig(
|
||||
level=logging.ERROR,
|
||||
level=logging.DEBUG,
|
||||
format="%(asctime)s :: {%(filename)10s:%(lineno)3d} :: %(funcName)s :: %(levelname)s :: %(message)s",
|
||||
)
|
||||
|
||||
@@ -32,7 +29,7 @@ SCHEMA_VERSION = 1
|
||||
def pits_init():
|
||||
db_path = utils.get_file_path(DB_FILENAME)
|
||||
|
||||
logging.debug("Search database in {}".format(db_path))
|
||||
logging.debug("Search database in %s", db_path)
|
||||
|
||||
if os.path.exists(db_path):
|
||||
valid = {"yes": True, "y": True, "ye": True}
|
||||
@@ -49,7 +46,7 @@ def pits_init():
|
||||
with sqlite3.connect(db_path) as conn:
|
||||
logging.info("Creating schema")
|
||||
schema_path = utils.get_file_path(SCHEMA_FILENAME)
|
||||
logging.debug("Schema file path: {}".format(schema_path))
|
||||
logging.debug("Schema file path: %s", schema_path)
|
||||
|
||||
with open(schema_path, "rt") as f:
|
||||
schema = f.read()
|
||||
@@ -128,7 +125,7 @@ def main():
|
||||
|
||||
conn = utils.create_connection(DB_FILENAME)
|
||||
last_action = action.read_current(conn)
|
||||
logging.debug("Last action: {}".format(last_action))
|
||||
logging.debug("Last action: %s", last_action)
|
||||
logging.debug(argv)
|
||||
logging.debug(argv[2:])
|
||||
cmd_handler[candidate][1](argv[2:], last_action, conn)
|
||||
|
||||
16
project.py
16
project.py
@@ -1,7 +1,4 @@
|
||||
# import sqlite3
|
||||
import os
|
||||
import argparse
|
||||
import json
|
||||
import getpass
|
||||
import datetime
|
||||
import logging
|
||||
@@ -28,7 +25,7 @@ class Project:
|
||||
|
||||
def handle_project(args, last_action, conn):
|
||||
logging.info("> handle project")
|
||||
logging.debug("args: " + str(args))
|
||||
logging.debug("args: %s", args)
|
||||
|
||||
if not args:
|
||||
list_project(last_action.project_id, conn)
|
||||
@@ -58,10 +55,9 @@ def handle_project(args, last_action, conn):
|
||||
else:
|
||||
project_id = last_action.project_id
|
||||
parse_project_args(project, args[1:])
|
||||
logging.debug("Project: ({}) {}".format(project_id, project))
|
||||
logging.debug("Project: (%s) %s", project_id, project)
|
||||
|
||||
edit_project(project, project_id, conn)
|
||||
# TODO To set as active project, us a -a option?
|
||||
|
||||
elif args[0] == "-d":
|
||||
if len(args) > 1:
|
||||
@@ -133,11 +129,11 @@ def edit_project(project, project_id, conn):
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
logging.debug("Project update args: {}".format(update_args))
|
||||
logging.debug("Project update args: %s", update_args)
|
||||
|
||||
query = "UPDATE project SET {} WHERE id = ?"
|
||||
query = query.format(", ".join("%s = '%s'" % (k, v) for k, v in update_args))
|
||||
logging.debug("update project query: " + query)
|
||||
logging.debug("update project query: %s", query)
|
||||
|
||||
cursor = conn.cursor()
|
||||
logging.debug("Do a project update")
|
||||
@@ -179,7 +175,7 @@ def list_project(active_project_id, conn):
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(query)
|
||||
for row in cursor.fetchall():
|
||||
logging.debug("Project row: {}".format(row))
|
||||
logging.debug("Project row: %s", row)
|
||||
project_id, username, name, status, nb_task = row
|
||||
# TODO Formatting track: https://stackoverflow.com/questions/9989334/create-nice-column-output-in-python
|
||||
print(
|
||||
@@ -219,7 +215,7 @@ def view_project_set_active(project_id, last_action, conn):
|
||||
"""
|
||||
cursor.execute(query, (project_id,))
|
||||
for row in cursor.fetchall():
|
||||
logging.debug("Task row: {}".format(row))
|
||||
logging.debug("Task row: %s", row)
|
||||
task_id, username, name, status, priority, date, time, nb_note = row
|
||||
message = date + time + name
|
||||
print(
|
||||
|
||||
14
task.py
14
task.py
@@ -1,7 +1,4 @@
|
||||
# import sqlite3
|
||||
import os
|
||||
import argparse
|
||||
import json
|
||||
import getpass
|
||||
import datetime
|
||||
import logging
|
||||
@@ -59,10 +56,9 @@ def handle_task(args, last_action, conn):
|
||||
last_action.task_id
|
||||
) # FIXME If no active tast - use incremental args_i
|
||||
parse_task_args(task, args[1:])
|
||||
logging.debug("Task: ({}) {}".format(task_id, task))
|
||||
logging.debug("Task: (%s) %s", task_id, task)
|
||||
|
||||
edit_task(task, task_id, last_action.project_id, conn)
|
||||
# TODO To set as active project, us a -a option?
|
||||
elif args[0] == "-d":
|
||||
# FIXME Duplicate code
|
||||
if len(args) > 1:
|
||||
@@ -190,11 +186,11 @@ def edit_task(task, task_id, project_id, conn):
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
logging.debug("Task update args: {}".format(update_args))
|
||||
logging.debug("Task update args: %s", update_args)
|
||||
|
||||
query = "UPDATE task SET {} WHERE id = ?"
|
||||
query = query.format(", ".join("%s = '%s'" % (k, v) for k, v in update_args))
|
||||
logging.debug("update task query: " + query)
|
||||
logging.debug("update task query: %s")
|
||||
|
||||
cursor = conn.cursor()
|
||||
logging.debug("Do a task update")
|
||||
@@ -204,7 +200,7 @@ def edit_task(task, task_id, project_id, conn):
|
||||
print("updated task {}: ({})".format(task_id, log_args))
|
||||
|
||||
# TODO Remove project id ?
|
||||
logging.debug("UPDATE TASK - ACTION MESSAGE : " + log_args)
|
||||
logging.debug("UPDATE TASK - ACTION MESSAGE : %s", log_args)
|
||||
record_action(
|
||||
cursor, TypeAction.UPDATE, "({})".format(log_args), project_id, task_id
|
||||
)
|
||||
@@ -303,7 +299,7 @@ def view_task_set_active(task_id, last_action, conn):
|
||||
"""
|
||||
cursor.execute(query, (task_id,))
|
||||
for row in cursor.fetchall():
|
||||
logging.debug("Note row: {}".format(row))
|
||||
logging.debug("Note row: %s", row)
|
||||
note_id, username, message = row
|
||||
print(
|
||||
" {} {:d}: ({}) {}".format(
|
||||
|
||||
Reference in New Issue
Block a user