A micro-blogging tool with multiple interfaces.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.3 KiB

#!/usr/bin/python
# -*- coding: utf-8 -*-
# Mitter, a Maemo client for Twitter.
# Copyright (C) 2007, 2008 Julio Biason, Deepak Sarda
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os.path
import glob
import logging
def find_image(image_name):
"""Using the iamge_name, search in the common places. Return the path for
the image or None if the image couldn't be found."""
# just because I'm a logging nut
log = logging.getLogger('mitterlib.find_image')
import os.path
import sys
# the order is the priority, so keep global paths before local paths
current_dir = os.path.abspath(os.path.dirname(__file__))
common_paths = [
os.path.join(sys.prefix, 'share', 'pixmaps'),
os.path.join('.', 'pixmaps'),
os.path.join(current_dir, '..', 'pixmaps')]
for path in common_paths:
filename = os.path.join(path, image_name)
log.debug('Checking %s...' % (filename))
if os.access(filename, os.F_OK):
log.debug('Default image is %s' % (filename))
return filename
return None
def module_search(source, ignore):
"""Search for modules in the source directory. Ignore any modules
indicated."""
base_dir = os.path.dirname(source)
modules = glob.glob(os.path.join(base_dir, '*.py'))
for module in modules:
module_name = os.path.basename(module)
if module_name in ignore:
# not a usable module
continue
try:
module_name = _import_name(module_name)
yield module_name
except ImportError, exc:
_log.debug('Module %s is not "importable"', module_name)
_log.debug(str(exc))
pass