コード例 #1
0
    def visit_Module(self, node):
        for s in node.body:
            self.visit(s)

        for v in self.names:
            if v in self.app.user_ns.keys() or v in builtins.__dir__():
                continue

            assign = ast.Assign(targets=[ast.Name(id=v, ctx=ast.Store())],
                                value=ast.Call(func=ast.Name(id='Symbol',
                                                             ctx=ast.Load()),
                                               args=[ast.Str(s=v)],
                                               keywords=[],
                                               starargs=None,
                                               kwargs=None))
            node.body.insert(0, assign)

        newnode = ast.Module(body=node.body)
        ast.copy_location(newnode, node)
        ast.fix_missing_locations(newnode)
        return newnode
コード例 #2
0
ファイル: conf.py プロジェクト: well69/pychess

def notify_add(key, func, *args, section=section):
    """The signature for func must be self, client, *args, **kwargs"""
    assert isinstance(key, str)
    global conid
    idkeyfuncs[conid] = (key, func, args, section)
    conid += 1
    return conid - 1


def notify_remove(conid):
    del idkeyfuncs[conid]


if "_" not in builtins.__dir__():

    def _(text):
        return text


DEFAULTS = {
    "General": {
        "firstName": username,
        "secondName": _("Guest"),
        "showEmt": False,
        "showEval": False,
        "showBlunder": True,
        "hideTabs": False,
        "closeAll": False,
        "faceToFace": False,
コード例 #3
0
                    'setprintoptions','frompyfunc','hdfstore','readhdf','readpickle','chmod'])
                  
F1 = set(['np','pd','re','fnmatch','datetime','calendar','json','types',
                    'Counter','BytesIO','load_workbook','path','makedirs','listdir',
                    'abs', 'all', 'any', 'ascii', 'bin', 'callable', 'chr',
                    'divmod', 'format', 'hasattr', 'hash', 'hex', 'id', 'isinstance',
                    'issubclass', 'iter', 'len', 'max', 'min', 'next', 'oct', 'ord',
                    'pow', 'repr', 'round', 'sorted', 'sum', 'None',  'bool', 
                    'complex', 'dict', 'enumerate', 'filter', 'float', 'frozenset',
                    'int','list','map','object','range','reversed','set','slice',
                    'staticmethod','str','super','tuple','type','zip'])

globs = {k:globals()[k] for k in globals() if k in F1}
globs.update({'os':{'path':path,'makedirs':makedirs,'listdir':listdir}})
import builtins
builts = {s:getattr(builtins,s) for s in builtins.__dir__() if s in F1}

import dakotaLib as DL
objs_DL = {k:getattr(DL,k) for k in DL.__dir__() if not (k.startswith('_'))}



# Define Constants:
FT_splitch = '_'
defaultDateFormat = '%Y/%m/%d'
empties = {'str':'','int':0,'bool':False,'date':np.datetime64('1970-01-01'),'float':np.nan}
typeFunctions = {'str':str,'int':int,'bool':bool,'float':float,'date':np.datetime64}
setDigits = set([chr(j) for j in range(48,58)])
setAlpha = set([chr(j) for j in range(65,91)] + [chr(j) for j in range(97,123)])
setAlphaUS = setAlpha.copy()
setAlphaUS.update('_')