コード例 #1
0
ファイル: database.py プロジェクト: Maggeych/worklog
 def __init__(self, dbCursor, name):
     self.c = dbCursor
     self.name = ''.join(chr for chr in name if chr.isalnum())
     self.overviewName = self.name + "_overview"
     self.openName = self.name + "_open"
     # Create the table and views if they don't exist yet.
     if not self.tableExists(self.name):
         if not utils.question("There is no work named '{}'. Create it?".format(name), "no"):
             utils.panic("Invalid work name.")
     self.createIfNotExists()
コード例 #2
0
def should_replace_playlist_track(track_tuple):
    saved = ''

    if 'Saved' in track_tuple[2]:
        saved = '[SAVED]'

    appears = ', '.join(map(lambda p: '"' + p['name'] + '"', track_tuple[2]))

    return question(
        f"{saved} Replace \"{track_tuple[0][TRACK_KEY_STR]}\" with \"{pretify_track(track_tuple[1])}\", Appears on: {appears}"
    )
コード例 #3
0
 def woods(self):
     choice = u.question("What do you want to do next?", [
         "Fight monsters", "Go exploring",
         "Follow that intersting tinkling noise"
     ])
     if choice == 1:
         self.fight_monsters()
     elif choice == 2:
         self.explore()
     elif choice == 3:
         self.go_to_village()
     else:
         self.disaster()
コード例 #4
0
ファイル: action.py プロジェクト: Maggeych/worklog
def delete(db, args):
    utils.checkNumberOfArgs(args, 1, True)
    utils.checkIsInt(args[0], True)
    id = args[0]

    print()
    if visualize.ticket(db, id) == False:
        utils.panic("There is no ticket #{}.".format(id))
    print()
    if utils.question("Really delete above ticket #{}?".format(id), "no"):
        db.deleteEntry(id)
        print("Deleted ticket #{}.".format(id))
    else:
        print("Aborted.")
コード例 #5
0
ファイル: action.py プロジェクト: Maggeych/worklog
def delete(db, args):
    utils.checkNumberOfArgs(args, 1, True)
    utils.checkIsInt(args[0], True)
    id = args[0]

    print()
    if visualize.ticket(db, id) == False:
        utils.panic("There is no ticket #{}.".format(id))
    print()
    if utils.question("Really delete above ticket #{}?".format(id), "no"):
        db.deleteEntry(id)
        print("Deleted ticket #{}.".format(id))
    else:
        print("Aborted.")
コード例 #6
0
ファイル: action.py プロジェクト: Maggeych/worklog
def add(db, args):
    if len(args) < 3:
        utils.panic("Command requires at least 3 argument(s) "
                "({} given).".format(len(args)))
    utils.checkIsDate(args[0])
    utils.checkIsTime(args[1])
    utils.checkIsTime(args[2])
    notes = " ".join(args[3:])
    visualize.data(args[0], args[1], args[2], notes)
    print()
    if utils.question("Create the above work record?"):
        db.createEntry(args[0], args[1], args[2], notes)
        print("Done:")
        print()
        visualize.lastInserted(db)
        print()
    else:
        print("Aborted.")
コード例 #7
0
ファイル: action.py プロジェクト: Maggeych/worklog
def add(db, args):
    if len(args) < 3:
        utils.panic("Command requires at least 3 argument(s) "
                    "({} given).".format(len(args)))
    utils.checkIsDate(args[0])
    utils.checkIsTime(args[1])
    utils.checkIsTime(args[2])
    notes = " ".join(args[3:])
    visualize.data(args[0], args[1], args[2], notes)
    print()
    if utils.question("Create the above work record?"):
        db.createEntry(args[0], args[1], args[2], notes)
        print("Done:")
        print()
        visualize.lastInserted(db)
        print()
    else:
        print("Aborted.")
コード例 #8
0
def should_replace_album(album_tuple):
    return question(f"Replace \"{pretify_album(album_tuple[0])}\" with \"{pretify_album(album_tuple[1])}\"")
コード例 #9
0
def main():
    parser.add_argument(
        '-v',
        '--version',
        action='version',
        version=__version__,
    )

    parser.add_argument('-c',
                        '--configure',
                        action='store_true',
                        dest='configure_requeriments',
                        help='Instalar dependências deste programa.')

    parser.add_argument('--clean',
                        action='store_true',
                        dest='clean_cache',
                        help='Apaga todos os arquivos baixados em cache.')

    parser.add_argument('-f',
                        '--info',
                        action='store',
                        nargs=1,
                        dest='pkg_info',
                        help='Mostra informações sobre um pacote')

    parser.add_argument('-l',
                        '--list',
                        action='store',
                        nargs=1,
                        dest='list_info',
                        help='Use --list apps ou --list installed')

    parser.add_argument('-i',
                        '--install',
                        action='store',
                        nargs='*',
                        dest='pkg_for_install',
                        type=str,
                        help='Instalar um pacote')

    parser.add_argument('-r',
                        '--remove',
                        nargs='*',
                        action='store',
                        dest='pkg_for_remove',
                        type=str,
                        help='Desisntala um pacote')

    parser.add_argument('-d',
                        '--downloadonly',
                        action='store_true',
                        dest='download_only',
                        help='Apenas baixa os pacotes sem instalar.')

    parser.add_argument('-y',
                        '--yes',
                        action='store_true',
                        dest='assumeyes',
                        help='Assume sim para indagações.')

    parser.add_argument('--download',
                        action='store',
                        dest='pkg_for_download',
                        type=str,
                        help='Somente baixa um pacote')

    parser.add_argument(
        '-u',
        '--self-update',
        action='store_true',
        dest='self_update',
        help='Instalar a versão mais recente deste programa apartir do github.'
    )

    args = parser.parse_args()
    if args.assumeyes:
        manager.assume_yes = True
    if args.clean_cache:
        from utils import appname, question
        from user_utils.commands import CommandsUtils
        from user_utils.userconf import ConfigAppDirs
        cfg = ConfigAppDirs(appname)
        cmds = CommandsUtils()
        files = os.listdir(cfg.get_dir_downloads())
        if bool(question(
                f'Deseja apagar {len(files)} arquivo(s) em cache')) == False:
            sys.exit(0)
        for file in files:
            path_file = os.path.join(cfg.get_dir_downloads(), file)
            print('Apagando ...', path_file)
            cmds.rmdir(path_file)

    if args.list_info:
        if args.list_info[0] == 'apps':
            manager.list_apps()
        elif args.list_info[0] == 'installed':
            manager.list_installed()
        elif args.list_info[0] == 'categories':
            manager.list_categories()
        else:
            print('ERRO')
            sys.exit(1)

    elif args.configure_requeriments:
        import configure
        configure.main()
    elif args.pkg_info:
        if not args.pkg_info[0] in obj_programs.keys():
            print(f'ERRO ... programa indisponível {args.pkg_info[0]}',
                  end=' ')
            print(
                'Use "--list apps" para listar todos os aplicativos disponíveis'
            )
            sys.exit(1)
        app = obj_programs[args.pkg_info[0]]
        manager.info(app)
    elif args.pkg_for_install:
        if args.download_only:
            # Criar lista de objetos para baixar.
            _list = []
            for key in args.pkg_for_install:
                if not key in manager.apps.keys():
                    print(f'ERRO programa indisponível ... {key}')
                    continue

                app = manager.apps[key]
                _list.append(app)
            manager.download_pkg(_list)
            return
        manager.install(args.pkg_for_install)

    elif args.pkg_for_remove:
        manager.uninstall(args.pkg_for_remove)
コード例 #10
0
#!/usr/bin/env python3
import sys
import os
import stat

import utils

utils.info('Setting things up')

dirname = utils.question('Enter day and part number (e.g. 1a)')

utils.debug(f'checking if ./{dirname} exists... ', end='')
if os.path.exists(dirname):
    print('yes')
    utils.error(f"{dirname} exists. Please select another "
                f"directory(another day).")
    sys.exit(1)

print('no')
os.mkdir(dirname)
utils.debug(f'created directory {dirname}')

template = f"""
import sys

sys.path.extend(['../'])
import utils

utils.info('Solver for day {dirname}')

helptext = f'''Usage: python3 {{sys.argv[0]}} [file]
コード例 #11
0
def should_replace_track(track_tuple):
    return question(
        f"[SAVED] Replace \"{track_tuple[0][TRACK_KEY_STR]}\" with \"{pretify_track(track_tuple[1])}\""
    )