コード例 #1
0
    def generate_code_bitmap(self, bitmap):
        """Returns a code fragment that generates an wxBitmap object

        bitmap: Bitmap definition string

        see: tmpl_inline_bitmap, get_inline_stmt_emptybitmap(), get_inline_stmt_artprovider()"""
        assert self.tmpl_inline_bitmap

        if not bitmap:
            return self.codegen.cn('wxNullBitmap')
        preview = self.codegen.preview

        if preview and ( bitmap.startswith('var:') or bitmap.startswith('code:') ):
            preview_icon = os.path.join(config.icons_path, "icon.xpm")
            return self.tmpl_inline_bitmap % { 'name': self.codegen.cn('wxBitmap'),
                                               'bitmap': self.codegen.quote_path(preview_icon),
                                               'bitmap_type': self.codegen.cn('wxBITMAP_TYPE_XPM') }

        if bitmap.startswith('var:'):
            return self.tmpl_inline_bitmap % { 'name': self.codegen.cn('wxBitmap'),
                                               'bitmap': bitmap[4:].strip(),
                                               'bitmap_type': self.codegen.cn('wxBITMAP_TYPE_ANY') }

        if bitmap.startswith('empty:'): return self.get_inline_stmt_emptybitmap(bitmap)
        if bitmap.startswith('art:'):   return self.get_inline_stmt_artprovider(bitmap) 
        if bitmap.startswith('code:'):  return '%s' % self.codegen.cn(bitmap[5:].strip())

        if preview:
            bitmap = misc.get_absolute_path(bitmap, True)

        return self.tmpl_inline_bitmap % { 'name': self.codegen.cn('wxBitmap'),
                                           'bitmap': self.codegen.quote_path(bitmap),
                                           'bitmap_type': self.codegen.cn('wxBITMAP_TYPE_ANY') }
コード例 #2
0
ファイル: dot-convert.py プロジェクト: yytang2012/linux-tools
def main():
    from docopt import docopt
    arguments = docopt(__doc__, version=__version__)

    """ Default value is svg"""
    if arguments['TYPE'] == 'png':
        opts = '-Tpng'
        fig_type = 'png'
    else:
        opts = '-Tsvg'
        fig_type = 'svg'

    if arguments['PATH'] is not None:
        folder_path = arguments['PATH']
    else:
        folder_path = './'

    from misc import get_absolute_path
    folder_path = get_absolute_path(folder_path)
    file_path_list = [os.path.join(folder_path, file_item) for file_item in os.listdir(folder_path)]
    file_path_list = list(
        filter(lambda file_path: os.path.isfile(file_path) and file_path[-4:] == '.dot', file_path_list))

    for file_item in file_path_list:
        input_file = file_item
        output_file = file_item[:-4] + '.' + fig_type
        cmd = 'dot {0} {1} > {2}'.format(opts, input_file, output_file)
        print(cmd)
        os.system(cmd);
コード例 #3
0
def main():
    input_dir = '~/novels/tmpNovels/'
    output_dir = '~/novels/downloads'
    input_path = get_absolute_path(input_dir)
    output_path = get_absolute_path(output_dir)

    for file in os.listdir(input_path):
        file_path = os.path.join(input_path, file)
        output_file_path = os.path.join(output_path, file)
        article = ''
        if os.path.isfile(file_path):
            with open(file_path, 'r') as f:
                for line in f.readlines():
                    article += line
            article = polish_content(article)
            with open(output_file_path, 'w') as f:
                f.write(article)
コード例 #4
0
def main():
    input_dir = '~/novels/tmpNovels/'
    output_dir = '~/novels/downloads'
    input_path = get_absolute_path(input_dir)
    output_path = get_absolute_path(output_dir)

    for file in os.listdir(input_path):
        file_path = os.path.join(input_path, file)
        output_file_path = os.path.join(output_path, file)
        article = ''
        if os.path.isfile(file_path):
            with open(file_path, 'r') as f:
                for line in f.readlines():
                    article += line
            article = polish_content(article)
            with open(output_file_path, 'w') as f:
                f.write(article)
コード例 #5
0
def main():
    fileType = '.java'
    if len(sys.argv) > 3:
        print("usage: %s /path/to/file .java" % sys.argv[0])
        sys.exit(-1)
    if len(sys.argv) == 1:
        rootDir = os.getcwd()
    else:
        rootDir = get_absolute_path(sys.argv[1])

    if not os.path.isdir(rootDir):
        print("%s does not exist!" % rootDir)
        sys.exit(-1)
    if len(sys.argv) == 3:
        fileType = sys.argv[2]
    count = count_files(rootDir, file_type=fileType)
    print("%-3d: %s" % (count, rootDir))
コード例 #6
0
ファイル: count-files.py プロジェクト: yytang2012/linux-tools
def main():
    fileType = '.java';
    if len(sys.argv) > 3:
        print("usage: %s /path/to/file .java" % sys.argv[0]);
        sys.exit(-1);
    if len(sys.argv) == 1:
        rootDir = os.getcwd();
    else:
        rootDir = get_absolute_path(sys.argv[1]);

    if not os.path.isdir(rootDir):
        print("%s does not exist!" % rootDir);
        sys.exit(-1);
    if len(sys.argv) == 3:
        fileType = sys.argv[2];
    count = count_files(rootDir, file_type=fileType);
    print("%-3d: %s" % (count, rootDir));
コード例 #7
0
    def get_preview_obj_bitmap(self, bitmap=None):
        """Create a wx.Bitmap or wx.EmptyBitmap from the given statement.
        If no statement is given, the instance variable named "bitmap" is used.

        bitmap: Bitmap definition (str or None)

        see: get_preview_obj_artprovider(), get_preview_obj_emptybitmap()"""
        if bitmap is None:
            bitmap = getattr(self, 'bitmap', None)

        if not bitmap:
            return compat.wx_EmptyBitmap(1, 1)

        if bitmap.startswith('var:') or bitmap.startswith('code:'):
            return compat.wx_EmptyBitmap(16, 16)
        elif bitmap.startswith('empty:'):
            return self.get_preview_obj_emptybitmap(bitmap)
        elif bitmap.startswith('art:'):
            return self.get_preview_obj_artprovider(bitmap)
        else:
            bitmap = misc.get_absolute_path(bitmap)
            return wx.Bitmap(bitmap, wx.BITMAP_TYPE_ANY)