Moving more toward being an actual library/script thing... mostly for practice since I'm no longer doing Python full-time

This commit is contained in:
Dan Buch 2012-02-06 09:44:30 -05:00
parent f0381040dc
commit c4122c3643
5 changed files with 44 additions and 3 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.egg-info

29
flickrscripts/__init__.py Normal file
View File

@ -0,0 +1,29 @@
from __future__ import print_function
import sys
from os.path import basename
__meta__ = dict(
name='flickrscripts',
version='0.1.0',
entry_points={
'console_scripts': [
'flickrscripts = flickrscripts:route',
],
},
)
USAGE = 'Usage: {prog} <subcommand> [args]'
def route(sysargs=sys.argv[:]):
try:
subcommand = sysargs.pop(1)
import_name = 'flickrscripts.{}'.format(subcommand)
module = __import__(import_name, fromlist=[import_name])
return module.main(sysargs)
except IndexError:
print(USAGE.format(prog=basename(sysargs[0])), file=sys.stderr)
print('You must provide a subcommand', file=sys.stderr)
return 1

View File

@ -5,7 +5,7 @@ import sys
from datetime import datetime, timedelta
from os.path import expanduser
from flickrscripts import setup_flickr
from flickrscripts.common import setup_flickr
class TimeWarper(object):
@ -32,7 +32,7 @@ class TimeWarper(object):
return 0
def _set_upload_date_for_photos(self, pagenum, page, set_to_date):
for i, photo in enumerate(page.findall('photos/photo'):
for i, photo in enumerate(page.findall('photos/photo')):
setdate_response = self.flickr.photos_setDates(
photo_id=photo.attrib['id'],
date_posted=set_to_date
@ -54,7 +54,8 @@ class TimeWarper(object):
def main(sysargs=sys.argv[:]):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
prog='flickrscripts timewarp')
parser.add_argument('set_to_date')
parser.add_argument('-q', '--search-query-param', default=[],
action='append', help='Add a key=value param to the search query list')

10
setup.py Normal file
View File

@ -0,0 +1,10 @@
import sys
from setuptools import setup
from flickrscripts import __meta__
if __name__ == '__main__':
setup(**__meta__)
sys.exit(0)