Beispiel #1
0
def _build_mod_list(mod_path: list, suffix: str, blacklist: list) -> list:
    """ _build_mod_list(mod_path, suffix) -> Add all the paths in mod_path to
    sys.path and return a list of all modules in sys.path ending in suffix.

    """

    from sys import path as sys_path

    mod_path = [mod_path] if type(mod_path) is str else mod_path
    blacklist = [blacklist] if type(blacklist) is str else blacklist

    # Add suffix to all names in blacklist.
    blacklist.extend(["%s%s" % (name, suffix) for name in blacklist if not name.endswith(suffix)])

    # Add the path of this file to the search path.
    mod_path.append(os_abspath(os_dirname(__file__)))

    # Add the path(s) in mod_path to sys.path so we can import from
    # them.
    [sys_path.extend((path, os_dirname(path.rstrip("/")))) for path in mod_path if path not in sys_path]

    # Build the list of modules ending in suffix in the mod_path(s).
    mod_list = (
        (path, name)
        for path in sys_path
        if os_isdir(path)
        for name in os_listdir(path)
        if name.endswith(suffix) and name not in blacklist
    )

    return mod_list
Beispiel #2
0
def _build_mod_list(mod_path, suffix, blacklist):
    """ _build_mod_list(mod_path, suffix) -> Add all the paths in mod_path to
    sys.path and return a list of all modules in sys.path ending in suffix.

    """

    from sys import path as sys_path

    mod_path = [mod_path] if type(mod_path) is str else mod_path
    blacklist = [blacklist] if type(blacklist) is str else blacklist

    # Add suffix to all names in blacklist.
    blacklist.extend([
        '%s%s' % (name, suffix) for name in blacklist
        if not name.endswith(suffix)
    ])

    # Add the path of this file to the search path.
    mod_path.append(os_abspath(os_dirname(__file__)))

    # Add the path(s) in mod_path to sys.path so we can import from
    # them.
    [
        sys_path.extend((path, os_dirname(path.rstrip('/'))))
        for path in mod_path if path not in sys_path
    ]

    # Build the list of modules ending in suffix in the mod_path(s).
    mod_list = ((path, name) for path in sys_path if os_isdir(path)
                for name in os_listdir(path)
                if name.endswith(suffix) and name not in blacklist)

    return mod_list
Beispiel #3
0
    def get_xsd_filepath(self, file_data):
        """提出者別タクソノミのxsdファイルパス取得"""
        # xsdファイル名取得
        element = self.root.find('.//%s' % self.link_schema_ref)

        if file_data is None:
            # 絶対パス生成
            return os_join(os_dirname(self.file), element.get(self.xlink_href))
        else:
            return os_basename(element.get(self.xlink_href))
Beispiel #4
0
def _build_mod_list(mod_path: list) -> list:
    """ _build_mod_list(mod_path, suffix) -> Add all the paths in mod_path to
    sys.path and return a list of all modules in sys.path ending in suffix.

    """

    mod_path = [mod_path] if type(mod_path) is str else mod_path

    # Add the path of this file to the search path.
    mod_path.append(os_abspath(os_dirname(__file__)))

    # Build the list of modules in mod_path(s).
    mod_list = ('{0}.{1}.{2}'.format(os_basename(path), \
                    os_basename(root).replace(os_basename(path), ''), \
                    name.rsplit('.', 1)[0]).replace('..', '.') \
                    for path in mod_path \
                        if os_isdir(path) \
                            for root, dirs, files in os_walk(path) \
                                for name in files \
                                    if name.endswith('.py'))

    return mod_list
Beispiel #5
0
def _build_mod_list(mod_path):
    """ _build_mod_list(mod_path, suffix) -> Add all the paths in mod_path to
    sys.path and return a list of all modules in sys.path ending in suffix.

    """

    mod_path = [mod_path] if type(mod_path) is str else mod_path

    # Add the path of this file to the search path.
    mod_path.append(os_abspath(os_dirname(__file__)))

    # Build the list of modules in mod_path(s).
    mod_list = ('{0}.{1}.{2}'.format(os_basename(path), \
                    os_basename(root).replace(os_basename(path), ''), \
                    name.rsplit('.', 1)[0]).replace('..', '.') \
                    for path in mod_path \
                        if os_isdir(path) \
                            for root, dirs, files in os_walk(path) \
                                for name in files \
                                    if name.endswith('.py'))

    return mod_list
Beispiel #6
0
# along with this program.  If not, see <http:#www.gnu.org/licenses/>.

from collections import defaultdict
from xml.dom.minidom import parseString
from textwrap import fill
from os.path import dirname as os_dirname
from os.path import join as os_join
import dbm
import sys
import re

import Sword

from .utils import *

data_path = os_join(os_dirname(__file__), 'data')


def book_gen():
    """ A Generator function that yields book names in order.

    """

    # Yield a list of all the book names in the bible.
    verse_key = Sword.VerseKey('Genesis 1:1')
    for testament in [1, 2]:
        for book in range(1, verse_key.bookCount(testament) + 1):
            yield(verse_key.bookName(testament, book))
# book_list = list(book_gen())
try:
    book_list = []
Beispiel #7
0
# along with this program.  If not, see <http:#www.gnu.org/licenses/>.

from collections import defaultdict
from xml.dom.minidom import parseString
from textwrap import fill
from os.path import dirname as os_dirname
from os.path import join as os_join
from difflib import get_close_matches
import gzip
import json
import re
import sys

from .utils import *

data_path = os_join(os_dirname(__file__), 'data')


class Verse(object):
    """ An index object of Bible references that can increment and decrement a
    reference.

    """

    # This information came from the sword libraries canon.h
    _books_tup = (
        ("Genesis", "Gen", "Gen", 50),
        ("Exodus", "Exod", "Exod", 40),
        ("Leviticus", "Lev", "Lev", 27),
        ("Numbers", "Num", "Num", 36),
        ("Deuteronomy", "Deut", "Deut", 34),
Beispiel #8
0
# along with this program.  If not, see <http:#www.gnu.org/licenses/>.

from collections import defaultdict
from xml.dom.minidom import parseString
from textwrap import fill
from os.path import dirname as os_dirname
from os.path import join as os_join
import dbm
import sys
import re

import Sword

from .utils import *

data_path = os_join(os_dirname(__file__), "data")


def book_gen():
    """ A Generator function that yields book names in order.

    """

    # Yield a list of all the book names in the bible.
    verse_key = Sword.VerseKey("Genesis 1:1")
    for testament in [1, 2]:
        for book in range(1, verse_key.bookCount(testament) + 1):
            yield (verse_key.bookName(testament, book))


book_list = list(book_gen())
def ensure_dir(file_path):
	if '/' in file_path:
		directory = os_dirname(file_path)
		if not os_exists(directory):
			os_makedirs(directory)