Skip to content

Commit

Permalink
Load pastebins from multiple directories instead of just from the las…
Browse files Browse the repository at this point in the history
…t valid one. (LP: #777902)
  • Loading branch information
stgraber committed Feb 12, 2012
1 parent da98b5f commit 0db7ecb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pastebinit
Original file line number Diff line number Diff line change
Expand Up @@ -58,33 +58,38 @@ try:
# - for source checkout, config in the checkout
# - user's overrides in ~/.pastebin.d
# Files found later override files found earlier.
pastebind = {}
for confdir in ['/usr/share/pastebin.d','/etc/pastebin.d',
os.path.join(os.path.dirname(__file__), 'pastebin.d'),
os.path.expanduser('~/.pastebin.d')]:
try:
confdirlist = os.listdir(confdir)
except OSError:
continue
pastebind = {}

for fileitem in confdirlist:
if fileitem.startswith('.'):
continue

filename = os.path.join(confdir, fileitem)
try:
bininstance = configobj.ConfigObj(filename)
except configobj.ConfigObjError, e:
print >> sys.stderr, '%s: %s' % (filename, e)
continue

try:
section = bininstance['pastebin']
except KeyError:
print >> sys.stderr, _('%s: no section [pastebin]') % filename
continue

try:
basename = section['basename']
except KeyError:
print >> sys.stderr, _("%s: no 'basename' in [pastebin]") % filename
continue

pastebind[basename] = bininstance
return pastebind

Expand Down

0 comments on commit 0db7ecb

Please sign in to comment.