Merge lp:~david4dev/dmedia/cli-update-options into lp:dmedia

Proposed by David Green
Status: Merged
Merged at revision: 121
Proposed branch: lp:~david4dev/dmedia/cli-update-options
Merge into: lp:dmedia
Diff against target: 137 lines (+47/-13)
2 files modified
dmedia (+26/-6)
dmedia.1 (+21/-7)
To merge this branch: bzr merge lp:~david4dev/dmedia/cli-update-options
Reviewer Review Type Date Requested Status
dmedia Dev Pending
Review via email: mp+42040@code.launchpad.net

Description of the change

Updates the command line interface to use general file types.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dmedia'
2--- dmedia 2010-11-26 17:14:03 +0000
3+++ dmedia 2010-11-28 12:11:16 +0000
4@@ -2,6 +2,7 @@
5
6 # Authors:
7 # Jason Gerard DeRose <jderose@novacut.com>
8+# David Green <david4dev@gmail.com>
9 #
10 # dmedia: distributed media library
11 # Copyright (C) 2010 Jason Gerard DeRose <jderose@novacut.com>
12@@ -79,7 +80,7 @@
13 You can browse through the dmedia database using a standard web-browser, like
14 this:
15
16- firefox ~/.local/share/desktop-couch/couchdb.html
17+ xdg-open ~/.local/share/desktop-couch/couchdb.html
18
19 Note that the sha1 hash is only being used as a stop-gap. dmedia will use the
20 Skein hash after its final constant tweaks are made. See:
21@@ -94,12 +95,13 @@
22 import logging
23 import dmedialib
24 import xdg.BaseDirectory
25+from dmedialib.constants import EXT_MAP
26
27 script = path.basename(sys.argv[0])
28
29 parser = optparse.OptionParser(
30 version=dmedialib.__version__,
31- usage='Usage: %s DIRECTORY EXTENSIONS...' % script,
32+ usage='Usage: %s DIRECTORY ' % script,
33 epilog='Example: %s /media/EOS_DIGITAL jpg cr2 mov' % script,
34 )
35 parser.add_option('--quick',
36@@ -117,6 +119,16 @@
37 default=[],
38 help='Add specified TAG to imported files',
39 )
40+parser.add_option('--type',
41+ action='append',
42+ default=[],
43+ help="Add specified TYPE to the list of file types to limit the import to. TYPE can be 'image', 'audio', 'video' or 'all'. 'all' is the default and represents 'image', 'audio' and 'video' files.",
44+)
45+parser.add_option('--extension',
46+ action='append',
47+ default=[],
48+ help='Add specified EXTENSION to the list of file extensions to limit the import to. By default, all file extensions that are recognised as audio, video or image file formats will be imported.',
49+)
50
51 (options, args) = parser.parse_args()
52
53@@ -126,14 +138,22 @@
54 ))
55
56
57-if len(args) < 2:
58+if len(args) < 1:
59 parser.print_usage()
60- sys.exit('ERROR: must provide DIRECTORY and at least one EXTENSION')
61+ sys.exit('ERROR: must provide DIRECTORY')
62 base = path.abspath(args[0])
63 if not path.isdir(base):
64 parser.print_usage()
65 sys.exit('ERROR: not a directory: %r' % base)
66-extensions = frozenset(a.lower() for a in args[1:])
67+
68+extensions = options.extension
69+for t in options.type:
70+ if EXT_MAP.has_key(t):
71+ for ext in EXT_MAP[t]:
72+ if not ext in extensions:
73+ extensions.append(ext)
74+if len(extensions) == 0:
75+ extensions += list(EXT_MAP['all'])
76
77 xdg_cache_path = xdg.BaseDirectory.xdg_cache_home
78 cache = path.join(xdg_cache_path, 'dmedia')
79@@ -177,4 +197,4 @@
80 )
81 print ''
82 print 'To browse dmedia database in CouchDB, run:'
83-print ' firefox file://%s' % dc
84+print ' xdg-open %s' % dc
85
86=== modified file 'dmedia.1'
87--- dmedia.1 2010-11-23 23:12:49 +0000
88+++ dmedia.1 2010-11-28 12:11:16 +0000
89@@ -10,7 +10,7 @@
90
91 .SH SYNOPSIS
92 .B dmedia
93-.RI DIRECTORY
94+.RI DIRECTORY
95 .RI EXTENSIONS...
96 .br
97
98@@ -28,14 +28,28 @@
99 Add imported files to specified PROJECT
100 .IP\fB\ --tag=TAG\fP
101 Add specified TAG to imported files
102+.IP\fB\ --type=TYPE\fP
103+Add specified TYPE to the list of file types to limit the import to. TYPE can be 'image', 'audio', 'video' or 'all'. 'all' is the default and represents 'image', 'audio' and 'video' files.
104+.IP\fB\ --extension=EXTENSION\fP
105+Add specified EXTENSION to the list of file extensions to limit the import to. By default, all file extensions that are recognised as audio, video or image file formats will be imported.
106
107
108 .SH EXAMPLES
109-.IP \fB\ dmedia\ /media/EOS_DIGITAL\ jpg\ cr2\fp
110-This will recursively import all JPG and CR2 files from your memory card mounted at '/media/EOS_DIGITAL'.
111-.PP
112-.IP \fB\ dmedia\ /usr/share/backgrounds\ jpg\ png\ --tag=wallpaper\ --tag=desktop\fp
113-This will add all files with the extensions 'png' and 'jpg' in the directory '/usr/share/backgrounds' and its subdirectories. The files will be tagged with 'wallpaper' and 'desktop' in the media database.
114+.IP \fB\ dmedia\ /media\fp
115+This will import all media files from all of your connected devices.
116+.PP
117+.IP \fB\ dmedia\ /media/EOS_DIGITAL\ --type=image\fp
118+This will recursively import all image files from your memory card mounted at '/media/EOS_DIGITAL'.
119+.PP
120+.IP \fB\ dmedia\ /usr/share/backgrounds\ --type=image\ --tag=wallpaper\ --tag=desktop\fp
121+This will add all image files in the directory '/usr/share/backgrounds' and its subdirectories. The files will be tagged with 'wallpaper' and 'desktop' in the media database.
122+.IP \fB\ dmedia\ /usr/share/pixmaps\ --extension=svg\ --tag=desktop\fp
123+This will import all icons with the 'svg' file extension from /usr/share/pixmaps.
124+.PP
125+.IP \fB\ dmedia\ ~/Videos\ --type=video\ --extension=webm\fp
126+This will import all video files in your Videos folder, as well as any file in that folder with the 'webm' extension. Due to being a new file format your system's MIME database may not recognise this format as a video; this will allow the webm files to be imported along with the other video files.
127+.PP
128+
129
130
131
132@@ -56,5 +70,5 @@
133 The development of dmedia is managed at http://launchpad.net/dmedia, where you can find the source code, report bugs and ask questions.
134
135 .SH AUTHOR
136-This man page was originally written by David Green <david4dev@gmail.com> using text from the README by Jason Gerard DeRose.
137+This man page was originally written by David Green <david4dev@gmail.com> using text from the README by Jason Gerard DeRose and has since been edited by the following authors: David Green <david4dev@gmail.com>.
138

Subscribers

People subscribed via source and target branches

to all changes: