Exemplo n.º 1
0
 def init_orb(self, i_nearcast):
     '''
     Orb is a special kind of spin that does nearcasting.
     '''
     # The orb has a method for changing this. It was a hassle and likely
     # confusing to new users to force the user to be constantly changing
     # this. Hence, we default it.
     spin_h = 'orb/%s' % (uniq())
     spin = Orb(spin_h=spin_h, engine=self, i_nearcast=i_nearcast)
     self._add_spin(spin_h=spin_h, spin=spin)
     return spin
Exemplo n.º 2
0
 def init_orb(self, i_nearcast):
     return Orb(spin_h='fake_engine/orb/%s' % uniq(),
                engine=self,
                i_nearcast=i_nearcast)
Exemplo n.º 3
0
def create_fake_sid():
    return 'fake_sid_%s' % uniq()
Exemplo n.º 4
0
# --------------------------------------------------------
#   util
# --------------------------------------------------------
def convert_camel_to_snake(name):
    '''from
    https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-snake-case
    '''
    s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
    return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()


# --------------------------------------------------------
#   cs parser
# --------------------------------------------------------
RCP_MODE_EXPECT_CLASS_LINE = uniq()
RCP_MODE_EXPECT_INIT_LINE = uniq()
RCP_MODE_EXPECT_FIELD_OR_TERM = uniq()

PATTERN_CLINE = re.compile('^ *class Cs[a-zA-Z0-9]*:$')
PATTERN_COMMENT = re.compile('^ *#')
PATTERN_STRING = re.compile('^ *"')
PATTERN_INIT = re.compile('^ *def __init__\(self\):$')
PATTERN_FIELD = re.compile('^ *self.[a-z0-9_]* = None$')


class RailCsParser:
    def __init__(self):
        self.cs_rcp_error = ns()
        self.cs_rcp_found = ns()
Exemplo n.º 5
0
 def init_spin(self, construct, **kwargs):
     spin_h = '%s/%s' % (str(construct), uniq())
     spin = construct(spin_h=spin_h, engine=self, **kwargs)
     self._add_spin(spin_h=spin_h, spin=spin)
     return spin
Exemplo n.º 6
0
 def init_testbridge(self):
     cog = self.nearcast_schema.init_testbridge(cog_h='test_receiver/%s' %
                                                (uniq()),
                                                orb=self,
                                                engine=self.engine)
     return cog