Commands Module

Commands are classes that encapsulate a set of actions based on a config. Each class registers itself on the command line so that it is callable from there but can also be called programmatically.

class py2facer.commands.base.BaseCommand(**kwargs)

The base from which all CLI commands are derived.

A BaseCommand object must have have several class variables:

  • COMMAND MUST be a UNIQUE str which will be used as a sub-parser of CLI_SUBPARSER

  • OPTIONS MUST be a list of dict objects. Each dict MUST be of the form:

    {'args' : ('-switch', '--long_switch'), # This may be a 1-tuple
     'kwargs' : {[OPTIONS TO PASS TO parser.add_argument]}
    }

When a Command object is created and executed it

  1. Sets up a basic empty cmd_config with defaults that come from OPTIONS (via _create_cmd_config())
  2. Attempts to read the ini config and set options in cmd_config base on what it finds. If there is no ini then this is skipped (via ini_config())
  3. Set any options that came in from the __init__() call (via api_config())
  4. Set any options that came in from the command line (via cli_config())
  5. Check that the final resultant config is sane (via check_config())
  6. Actually do the command (via do_command())

Outside users of a Command object are expected to init the object (possibly with kwargs if only calling from the API) and then to call execute()

Variables:
  • cmd_config – A dict of all cleaned settings for tclse Command object.
  • _api_config – A dict of all the kwargs passed in to __init__()
COMMAND

Defines the py2TheFaceR.py COMMAND [options] part of the CLI interface

INI_OPTIONS

The keywords to expect in INI_SECTION

INI_SECTION

The INI section name additional config may be defined in

OPTIONS

Options that are provided to the argparse module via the meta-class

api_config(api_config)

Update cmd_config using the destinations defined in OPTIONS

Params api_config:
 The kwargs passed in to the __init__()
check_config()

Last chance to catch semantic errors in the config before executing

cli_config(cli_settings)

Migrates the config from the argparser to cmd_config

Parameters:cli_settings
ini_config(cfg_parser)

Base level parser. This method should be overridden by a child class

Parameters:cfg_parser (ConfigParser.SafeConfigParser) – One that has already loaded the ini file
py2facer.commands.base.CLI_PARSER

The sort-of global ArgumentParser. This is where all the CLI options end up.

py2facer.commands.base.CLI_SUBPARSER

The sort-of global subparser, so that sub commands a-la svn style can exist.

class py2facer.commands.base.SyncContacts(**kwargs)

Link a set of Google contacts with the corresponding flickr id’s

class py2facer.commands.base.SyncPhotos(**kwargs)

For a set of photos add the facial data to flickr using the the database as a reference for Google contact –> flickr user

Previous topic

Running py2FaceR

Next topic

Flickr Module

This Page