Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _get_path(self, fname):
return os.path.join(CACHE_DIR, fname)
def get(self, img_name):
hname = self._hash(img_name)
for fname in os.listdir(CACHE_DIR):
if fname.startswith(hname):
logger.debug('get img cache for %s' % img_name)
return self._get_path(fname)
return None
def ensure_dirs():
for d in (HOME_DIR, DATA_DIR,
USER_THEMES_DIR, USER_PLUGINS_DIR,
CACHE_DIR, SONG_DIR, COLLECTIONS_DIR):
if not os.path.exists(d):
os.mkdir(d)
import argparse
import asyncio
import os
import textwrap
import sys
from contextlib import contextmanager
from socket import socket, AF_INET, SOCK_STREAM
from fuocore.cmds import exec_cmd, Cmd
from fuocore.cmds.helpers import show_song
from fuocore.protocol import Parser
from feeluown.consts import CACHE_DIR
OUTPUT_CACHE_FILEPATH = os.path.join(CACHE_DIR, 'cli.out')
def print_error(*args, **kwargs):
print('\033[0;31m', end='')
print(*args, **kwargs)
print('\033[0m', end='')
def setup_cli_argparse(parser):
subparsers = parser.add_subparsers(dest='cmd')
play_parser = subparsers.add_parser(
'play',
description=textwrap.dedent('''\
Example:
- fuo play fuo://netease/songs/3027393