/usr/share/gallery-uploader/galleryuploader_lib/config.py is in gallery-uploader 2.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | import sys, os
from os import path
from xdg.BaseDirectory import xdg_config_home
########################## CONFIGURATION #######################################
script_path = path.realpath( path.join( sys.path[0], sys.argv[0] ) )
not_installed_dir = path.dirname( script_path )
STUFF_DIR = LOCALE_DIR = None
if path.exists( path.join( not_installed_dir, 'stuff', 'gallery.svg' ) ):
STUFF_DIR = path.join( not_installed_dir, 'stuff' )
if path.exists( path.join( not_installed_dir, 'locale' ) ):
LOCALE_DIR = path.join( not_installed_dir, 'locale' )
else:
for directory in [sys.prefix, path.join( sys.prefix, 'local' )]:
installed_root_dir = path.join( directory, 'share' )
if path.exists( path.join( installed_root_dir, 'gallery-uploader', 'stuff', 'gallery.svg' ) ):
LOCALE_DIR = path.join( installed_root_dir, 'locale' )
if not STUFF_DIR:
STUFF_DIR = path.join( installed_root_dir, 'gallery-uploader', 'stuff' )
break
# Note: no reasonable setup can have "locale" and not "stuff".
from ConfigParser import ConfigParser, NoOptionError
CONFIG_DIR = path.join( xdg_config_home, 'gallery-uploader' )
CONFIG_PATH = path.join( CONFIG_DIR, 'config.ini' )
PROFILES_PATH = path.join( CONFIG_DIR, 'profiles.ini' )
if not path.exists( CONFIG_DIR ):
# There _is not_ a new config
os.mkdir( CONFIG_DIR )
print "created", CONFIG_DIR
# Is there an old config?
old_config_dir = path.expanduser( '~/.gup' )
old_config_path = path.join( old_config_dir, 'config.ini' )
if path.exists( old_config_path ):
# Yes... migrate!
old_profiles = open( old_config_path )
profiles = old_profiles.read()
old_profiles.close()
new_profiles = open( PROFILES_PATH, 'w' )
new_profiles.write( profiles )
new_profiles.close()
readme = open( path.join( old_config_dir, 'README' ), 'w' )
readme.write( """This directory may have been created by a past version of gallery uploader.
If you do not use the "gup" library directly, you can now safely delete it,
since all profiles informations were transferred in
%s.""" % PROFILES_PATH )
readme.close()
profiles = ConfigParser()
profiles.read( [PROFILES_PATH] )
config = ConfigParser()
config.read( [CONFIG_PATH] )
########################## END OF CONFIGURATION ################################
########################## LOCALIZATION ########################################
import locale
import gettext
APP = 'gallery_uploader'
gettext.install(APP, localedir=LOCALE_DIR, unicode=True)
# For Gtk.Builders:
locale.bindtextdomain(APP, LOCALE_DIR)
########################## END OF LOCALIZATION #################################
|