Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "appdirs in functional component" in Python

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'appdirs' in functional components in Python. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

def test_helpers(self):
        self.assertIsInstance(
            appdirs.user_data_dir('MyApp', 'MyCompany'), STRING_TYPE)
        self.assertIsInstance(
            appdirs.site_data_dir('MyApp', 'MyCompany'), STRING_TYPE)
        self.assertIsInstance(
            appdirs.user_cache_dir('MyApp', 'MyCompany'), STRING_TYPE)
        self.assertIsInstance(
            appdirs.user_state_dir('MyApp', 'MyCompany'), STRING_TYPE)
        self.assertIsInstance(
            appdirs.user_log_dir('MyApp', 'MyCompany'), STRING_TYPE)
def test_helpers(self):
        self.assertIsInstance(
            appdirs.user_data_dir('MyApp', 'MyCompany'), STRING_TYPE)
        self.assertIsInstance(
            appdirs.site_data_dir('MyApp', 'MyCompany'), STRING_TYPE)
        self.assertIsInstance(
            appdirs.user_cache_dir('MyApp', 'MyCompany'), STRING_TYPE)
        self.assertIsInstance(
            appdirs.user_state_dir('MyApp', 'MyCompany'), STRING_TYPE)
        self.assertIsInstance(
            appdirs.user_log_dir('MyApp', 'MyCompany'), STRING_TYPE)
def main():
    args = docopt.docopt(__doc__)
    config_dir = appdirs.user_data_dir("RSS-filter", "U2Ft")
    config, filters = check_config(config_dir)
    logging.basicConfig(filename=os.path.join(config_dir, "RSS-filter.log"), level=logging.INFO,
                        datefmt="%Y-%m-%d %H:%M:%S", format="%(asctime)s: %(message)s")

    # silence requests.packages.urllib3's logging of every connection at level INFO
    requests_logger = logging.getLogger("requests.packages.urllib3")
    requests_logger.setLevel(logging.WARNING)

    if isinstance(filters, tuple) or args["--edit"]:
        edit_filters(filters, config_dir)
        exit(4)

    feedbin = Feedbin(config["username"], config["password"])

    if args["--list"]:
        list_feeds(feedbin)
def load_config(filename):
    """Load config from the specified file and return the parsed config"""
    # Get a path to the file. If it was specified, it should be fine.
    # If it was not specified, assume it's config.ini in the script's dir.
    config_dir = appdirs.user_config_dir("telegram-export")

    if not filename:
        filename = os.path.join(config_dir, 'config.ini')

    if not os.path.isfile(filename):
        logger.warning("No config file! Make one in {} and find an example "
                       "config at https://github.com/expectocode/"
                       "telegram-export/blob/master/config.ini.example."
                       "Alternatively, use --config-file FILE".format(filename))
        exit(1)

    defaults = {
        'SessionName': 'exporter',
        'OutputDirectory': '.',
        'MediaWhitelist': 'chatphoto, photo, sticker',
        'MaxSize': '1MB',
tile.from_shape(ex.shape, dtype, tile_type=tile_type),
                  hint=worker_scores[i % len(worker_scores)][0])
  elif FLAGS.tile_assignment_strategy == 'serpentine':
    for ex, i in extents.iteritems():
      j = i % ctx.num_workers
      if (i / ctx.num_workers) % 2 == 1:
        j = (ctx.num_workers - 1 - j)

      tiles[ex] = ctx.create(
                    tile.from_shape(ex.shape, dtype, tile_type=tile_type),
                    hint=j)
  elif FLAGS.tile_assignment_strategy == 'static':
    all_extents = list(extents.iterkeys())
    all_extents.sort()
    if hasattr(appdirs, 'user_config_dir'):  # user_config_dir new to v1.3.0
      map_file = appdirs.user_config_dir('spartan') + '/tiles_map'
    else:
      map_file = appdirs.user_data_dir('spartan') + '/tiles_map'
    with open(map_file) as fp:
      for ex in all_extents:
        worker = int(fp.readline().strip())
        tiles[ex] = ctx.create(
                    tile.from_shape(ex.shape, dtype, tile_type=tile_type),
                    hint=worker)
  else: #  random
    for ex in extents:
      tiles[ex] = ctx.create(tile.from_shape(ex.shape, dtype, tile_type=tile_type))

  for ex in extents:
    tiles[ex] = tiles[ex].wait().tile_id

  #for ex, i in extents.iteritems():
if cli_args.debug:
        logging.getLogger().setLevel(logging.DEBUG)
    else:
        logging.getLogger().setLevel(logging.INFO)

    # Build up a list of potential config files to parse.
    config_paths = []
    try:
        import appdirs
    except ImportError:
        logging.warn("appdirs not installed, not reading site/user config")
    else:
        config_paths.append(
            os.path.join(
                appdirs.user_config_dir(APP_NAME, APP_AUTHOR),
                CONFIG_FILE_NAME))
        config_paths.append(
            os.path.join(
                appdirs.site_config_dir(APP_NAME, APP_AUTHOR),
                CONFIG_FILE_NAME))
    if cli_args.config:
        config_paths.append(cli_args.config)

    if cli_args.cmd == "print_config_paths":
        for config_path in config_paths:
            print config_path
        sys.exit(0)

    # Attempt to open each config file, and update the `cfg` dict with each
    # one.
    cfg = {}
import hmac
import os
import json

import datetime

import click
import validators
from appdirs import user_config_dir

import lecli

AUTH_SECTION = 'Auth'
URL_SECTION = 'Url'
CONFIG = ConfigParser.ConfigParser()
CONFIG_FILE_PATH = os.path.join(user_config_dir(lecli.__name__), 'config.ini')
DEFAULT_API_URL = 'https://rest.logentries.com'


def print_config_error_and_exit(section=None, config_key=None, value=None):
    """
    Print appropriate apiutils error message and exit.
    """
    if not section:
        click.echo("Error: Configuration file '%s' not found" % CONFIG_FILE_PATH, err=True)
    elif not config_key:
        click.echo("Error: Section '%s' was not found in configuration file(%s)" %
                   (section, CONFIG_FILE_PATH), err=True)
    elif not value:
        click.echo("Error: Configuration key for %s was not found in configuration file(%s) in "
                   "'%s' section" % (config_key, CONFIG_FILE_PATH, section), err=True)
    else:
group = parser.add_mutually_exclusive_group()

    group.add_argument("--auto-offset", action="store_true", dest="auto_offset", default=False,
                       help="determine offset automatically")
    group.add_argument("-o", "--offset", type=int, dest="offset", default=10,
                       help="UTC time offset in hours, must be less than or equal to +10")

    parser.add_argument("-l", "--level", type=int, choices=[4, 8, 16, 20], dest="level", default=4,
                        help="increases the quality (and the size) of each tile. possible values are 4, 8, 16, 20")
    parser.add_argument("-d", "--deadline", type=int, dest="deadline", default=6,
                        help="deadline in minutes to download all the tiles, set 0 to cancel")
    parser.add_argument("--save-battery", action="store_true", dest="save_battery", default=False,
                        help="stop refreshing on battery")
    parser.add_argument("--output-dir", type=str, dest="output_dir",
                        help="directory to save the temporary background image",
                        default=appdirs.user_cache_dir(appname="himawaripy", appauthor=False))
    parser.add_argument("--dont-change", action="store_true", dest="dont_change", default=False,
                        help="don't change the wallpaper (just download it)")

    args = parser.parse_args()

    if not -12 <= args.offset <= 10:
        sys.exit("OFFSET has to be between -12 and +10!\n")

    if not args.deadline >= 0:
        sys.exit("DEADLINE has to be greater than (or equal to if you want to disable) zero!\n")

    return args
import appdirs
import sys
import os

APP_NAME = "Reaper"
APP_AUTHOR = "UQ"

DATA_DIR = appdirs.user_data_dir(APP_NAME, APP_AUTHOR)
LOG_DIR = appdirs.user_log_dir(APP_NAME, APP_AUTHOR)
CACHE_DIR = appdirs.user_cache_dir(APP_NAME, APP_AUTHOR)

def _calc_path(path):
    head, tail = os.path.split(path)
    if tail == 'reaper':
        return path
    else:
        return _calc_path(head)

BUNDLE_DIR = sys._MEIPASS if getattr(sys, "frozen", False) else \
    _calc_path(os.path.dirname(os.path.abspath(__file__)))
def doDownload(manifest):
    manifestPath = Path(manifest)
    targetDirPath = manifestPath.parent

    manifestText = manifestPath.open().read()
    manifestText = manifestText.replace('\r', '').replace('\n', '')

    manifestJson = json.loads(manifestText)

    overridePath = Path(targetDirPath, manifestJson['overrides'])
    minecraftPath = Path(targetDirPath, "minecraft")
    if overridePath.exists():
        shutil.move(str(overridePath), str(minecraftPath))

    downloaderDirs = appdirs.AppDirs(appname="cursePackDownloader", appauthor="portablejim")
    cache_path = Path(downloaderDirs.user_cache_dir, "curseCache")

    # Attempt to set proper portable data directory if asked for
    if args.portable:
        if '__file__' in globals():
            cache_path = Path(os.path.dirname(os.path.realpath(__file__)), "CPD_data")
        else:
            print("Portable data dir not supported for interpreter environment")
            exit(2)

    if not cache_path.exists():
        cache_path.mkdir(parents=True)
    print("Cache path : %s" % (cache_path))

    if not minecraftPath.exists():
        minecraftPath.mkdir()

Is your System Free of Underlying Vulnerabilities?
Find Out Now