예제 #1
0
def make(args):
    from hwp5.plat import get_xslt
    from hwp5.importhelper import pkg_resources_filename
    from tempfile import mkstemp
    from hwp5.xmlmodel import Hwp5File

    hwp5_filename = args['<hwp5file>']
    rootname = os.path.basename(hwp5_filename)
    if rootname.lower().endswith('.hwp'):
        rootname = rootname[0:-4]
    txt_path = rootname + '.txt'

    xslt = get_xslt()
    plaintext_xsl = pkg_resources_filename('hwp5', 'xsl/plaintext.xsl')

    hwp5file = Hwp5File(hwp5_filename)
    try:
        xhwp5_fd, xhwp5_path = mkstemp()
        try:
            xhwp5_file = os.fdopen(xhwp5_fd, 'w')
            try:
                hwp5file.xmlevents().dump(xhwp5_file)
            finally:
                xhwp5_file.close()

            xslt(plaintext_xsl, xhwp5_path, txt_path)
        finally:
            os.unlink(xhwp5_path)
    finally:
        hwp5file.close()
예제 #2
0
def make(args):
    from hwp5.plat import get_xslt
    from hwp5.importhelper import pkg_resources_filename
    from tempfile import mkstemp
    from hwp5.xmlmodel import Hwp5File

    hwp5_filename = args['<hwp5file>']
    rootname = os.path.basename(hwp5_filename)
    if rootname.lower().endswith('.hwp'):
        rootname = rootname[0:-4]
    txt_path = rootname + '.txt'

    xslt = get_xslt()
    plaintext_xsl = pkg_resources_filename('hwp5', 'xsl/plaintext.xsl')

    hwp5file = Hwp5File(hwp5_filename)
    try:
        xhwp5_fd, xhwp5_path = mkstemp()
        try:
            xhwp5_file = os.fdopen(xhwp5_fd, 'w')
            try:
                hwp5file.xmlevents().dump(xhwp5_file)
            finally:
                xhwp5_file.close()

            xslt(plaintext_xsl, xhwp5_path, txt_path)
        finally:
            os.unlink(xhwp5_path)
    finally:
        hwp5file.close()
예제 #3
0
파일: hwp5html.py 프로젝트: sececter/pyhwp
def hwp5_resources_path(res_path):
    try:
        path = pkg_resources_filename('hwp5', res_path)
    except Exception:
        logger.info('%s: pkg_resources_filename failed; using resource_stream',
                    res_path)
        with mkstemp_open() as (path, g):
            import pkg_resources
            f = pkg_resources.resource_stream('hwp5', res_path)
            try:
                shutil.copyfileobj(f, g)
                g.close()
                yield path
            finally:
                f.close()
    else:
        yield path
예제 #4
0
파일: hwp5odt.py 프로젝트: hanul93/pyhwp
def hwp5_resources_path(path):
    yield pkg_resources_filename('hwp5', path)
예제 #5
0
파일: hwp5odt.py 프로젝트: hanul93/pyhwp
def hwp5_resources_filename(path):
    ''' get paths of 'hwp5' package resources '''
    return pkg_resources_filename('hwp5', path)
예제 #6
0
파일: __init__.py 프로젝트: hanul93/pyhwp
def get_fixture_path(filename):
    from hwp5.importhelper import pkg_resources_filename
    return pkg_resources_filename(__name__, filename)
예제 #7
0
def get_fixture_path(filename):
    from hwp5.importhelper import pkg_resources_filename
    return pkg_resources_filename(__name__, filename)
예제 #8
0
def hwp5_resources_path(path):
    yield pkg_resources_filename("hwp5", path)
예제 #9
0
def hwp5_resources_filename(path):
    """ get paths of 'hwp5' package resources """
    return pkg_resources_filename("hwp5", path)
예제 #10
0
파일: hwp5odt.py 프로젝트: sececter/pyhwp
def hwp5_resources_path(path):
    yield pkg_resources_filename('hwp5', path)
예제 #11
0
파일: hwp5odt.py 프로젝트: sececter/pyhwp
def hwp5_resources_filename(path):
    ''' get paths of 'hwp5' package resources '''
    return pkg_resources_filename('hwp5', path)