python类user_data_dir()的实例源码

dirs.py 文件源码 项目:aw-core 作者: ActivityWatch 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_data_dir(module_name: Optional[str]) -> str:
    data_dir = appdirs.user_data_dir("activitywatch")
    return os.path.join(data_dir, module_name) if module_name else data_dir
musicfiledb.py 文件源码 项目:synthesizer 作者: irmen 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, dbfile=None, scan_changes=True, silent=False):
        if not dbfile:
            dblocation = appdirs.user_data_dir("PythonJukebox", "Razorvine")
            os.makedirs(dblocation, mode=0o700, exist_ok=True)
            dbfile = os.path.join(dblocation, "tracks.sqlite")
        dbfile = os.path.abspath(dbfile)
        self.dbfile = dbfile
        self.dbconn = sqlite3.connect(dbfile, detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES)
        self.dbconn.row_factory = sqlite3.Row   # make sure we can get results by column name
        self.dbconn.execute("PRAGMA foreign_keys=ON")
        try:
            self.dbconn.execute("SELECT COUNT(*) FROM tracks").fetchone()
            if not silent:
                print("Connected to database.")
                print("Database file:", dbfile)
            if scan_changes:
                self.scan_changes()
        except sqlite3.OperationalError:
            # the table does not yet exist, create the schema
            if not silent:
                print("Creating new database.")
                print("Database file:", dbfile)
            self.dbconn.execute("""CREATE TABLE tracks
                (
                    id integer PRIMARY KEY,
                    title nvarchar(260),
                    artist nvarchar(260),
                    album nvarchar(260),
                    year int,
                    genre nvarchar(100),
                    duration real NOT NULL,
                    modified timestamp NOT NULL,
                    location nvarchar(500) NOT NULL,
                    hash char(40) NOT NULL UNIQUE
                );""")
box.py 文件源码 项目:synthesizer 作者: irmen 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self):
        super().__init__()
        self.config_location = appdirs.user_data_dir("PythonJukebox", "Razorvine")
        os.makedirs(self.config_location, mode=0o700, exist_ok=True)
        default_font = tk.font.nametofont("TkDefaultFont")
        default_font["size"] = abs(default_font["size"])+2
        default_font = tk.font.nametofont("TkTextFont")
        default_font["size"] = abs(default_font["size"])+2
        self.title("Jukebox")
        f = ttk.Frame()
        f1 = ttk.Frame(f)
        self.firstTrackFrame = TrackFrame(f1, "Track 1")
        self.secondTrackFrame = TrackFrame(f1, "Track 2")
        self.levelmeterFrame = LevelmeterFrame(f1)
        self.playlistFrame = PlaylistFrame(self, f1)
        self.firstTrackFrame.pack(side=tk.LEFT, fill=tk.Y)
        self.secondTrackFrame.pack(side=tk.LEFT, fill=tk.Y)
        self.levelmeterFrame.pack(side=tk.LEFT, fill=tk.Y)
        self.playlistFrame.pack(side=tk.LEFT, fill=tk.Y)
        f1.pack(side=tk.TOP)
        f2 = ttk.Frame(f)
        self.searchFrame = SearchFrame(self, f2)
        self.searchFrame.pack()
        f2.pack(side=tk.TOP)
        f3 = ttk.Frame(f)
        optionsFrame = ttk.Frame(f3)
        ttk.Button(optionsFrame, text="Database Config", command=self.do_database_config).pack()
        optionsFrame.pack(side=tk.LEFT)
        self.effectsFrame = EffectsFrame(self, f3)
        self.effectsFrame.pack()
        f3.pack(side=tk.TOP)
        self.statusbar = ttk.Label(f, text="<status>", relief=tk.GROOVE, anchor=tk.CENTER)
        self.statusbar.pack(fill=tk.X, expand=True)
        f.pack()
        self.player = Player(self, (self.firstTrackFrame, self.secondTrackFrame))
        self.backend = None
        self.backend_process = None
        self.show_status("Connecting to backend file service...")
        self.after(500, self.connect_backend)
release.py 文件源码 项目:coincurve 作者: ofek 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def main():
    here = os.path.dirname(os.path.abspath(__file__))
    os.chdir(here)

    version = sys.argv[-1]
    delete = not not sys.argv[-2] == '-d'
    delete_only = not not sys.argv[-2] == '--d'

    try:
        subprocess.call('git -h')
        git_path = 'git'
    except:
        git_path = None

    # Assume Windows portable Git
    if git_path is None:
        github_dir = os.path.join(appdirs.user_data_dir(), 'GitHub')
        for d in os.listdir(github_dir):
            if d.startswith('PortableGit'):
                git_path = os.path.join(github_dir, d, 'cmd', 'git.exe')

    if git_path is None:
        raise OSError('Unable to find git executable.')

    cmds = [
        '{0} tag -a {1} -m "Version {1}"'.format(git_path, version),
        '{} push origin {}'.format(git_path, version)
    ]
    delete_cmd = '{} tag -d {}'.format(git_path, version)

    if delete:
        cmds.insert(0, delete_cmd)
    elif delete_only:
        cmds = [delete_cmd]

    for cmd in cmds:
        subprocess.call(cmd)

    print(cmds)


问题


面经


文章

微信
公众号

扫码关注公众号