21
21
import urllib, os, sys, re, getopt, select, xml.dom.minidom, gettext
22
22
from gettext import gettext as _
23
from configobj import ConfigObj
25
25
gettext.textdomain("pastebinit")
36
36
def preloadPastebins():
37
confdir = '/etc/pastebin.d/'
38
confdirlist = os.listdir(confdir)
40
for fileitem in confdirlist:
41
bininstance = ConfigObj(confdir + fileitem)
42
basename = bininstance['pastebin']['basename']
43
pastebind[basename] = bininstance
37
# Check several places for config files:
38
# - global config in /etc/pastebin.d
39
# - for source checkout, config in the checkout
40
# - user's overrides in ~/.pastebin.d
41
# Files found later override files found earlier.
42
for confdir in ['/etc/pastebin.d',
43
os.path.join(os.path.dirname(__file__), 'pastebin.d'),
44
os.path.expanduser('~/.pastebin.d')]:
46
confdirlist = os.listdir(confdir)
50
for fileitem in confdirlist:
51
if fileitem.startswith('.'):
53
filename = os.path.join(confdir, fileitem)
55
bininstance = configobj.ConfigObj(filename)
56
except configobj.ConfigObjError, e:
57
print >> sys.stderr, '%s: %s' % (filename, e)
60
section = bininstance['pastebin']
62
print >> sys.stderr, _('%s: no section [pastebin]') % filename
65
basename = section['basename']
67
print >> sys.stderr, _("%s: no 'basename' in [pastebin]") % filename
69
pastebind[basename] = bininstance
46
72
# pastey.net obfuscates parent ids for replies. Rather than taking the
47
73
# post ID given as the parent ID, we must handle this by going to that