Ejemplo n.º 1
0
    def __init__(self, params, data, desc=''):
        """params is a list of (name, validator, defaults) tuples."""
        wx.Dialog.__init__(self, None, -1, "Specify parameters")

        text =wx.StaticText(self, -1, desc)
        # create the entries
        labels = []
        entries = []
        for name, validator, default in params:
            labels.append(wx.StaticText(self, -1, name + ': '))
            entries.append(wx.TextCtrl(self, validator=factory.factory('validators', validator, data, name), value=default))
        okay = wx.Button(self, wx.ID_OK)
        okay.SetDefault()
        cancel = wx.Button(self, wx.ID_CANCEL)

        # layout
        fgs = wx.FlexGridSizer(len(params)+1, 2, 5, 5)
        for label, entry in zip(labels, entries):
            fgs.Add(label, 0, wx.ALIGN_RIGHT)
            fgs.Add(entry, 0, wx.EXPAND)
        fgs.AddGrowableCol(1)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(text, 0, wx.ALIGN_CENTRE|wx.ALL, border=10)
        sizer.Add(fgs)
        btns = wx.StdDialogButtonSizer()
        btns.Add(okay)
        btns.Add(cancel)
        sizer.Add(btns, 0, wx.EXPAND|wx.ALL, 5)
        self.SetSizer(sizer)
        sizer.Fit(self)
Ejemplo n.º 2
0
    def init_factory_entity(self):
        for j in range(self.mine_coal):
            temp = fac.factory()


#    def worker_consume(self):
#        stock=[10,100,100,50,10]
#        demand=[50,50,50,50,50]
#        price=np.zeros(5)
#        for i in range(5):
#            price[i]=demand[i]/stock[i]
#
#        for i in range(len(self.worker_list)):
#            condition,unhappy=self.worker_list[i].consume(stock,demand,price,self.worker_pp)
#            print("Stock",stock)
#            print("demand",demand)
#            print("condition",condition)
#            print("unhappy",unhappy)
#            print("-"*20)
Ejemplo n.º 3
0
    reader.read_05evtCFile()  # Read *_05evt.c
    reader.readEqFictiveXml()  # Read the fictitious equation file
    reader.read_structXmlFile(
    )  # Read *_structure.xml (contains structure elements)
    reader.read_functionsHeader()  # Read *_functions.h
    reader.read_functionsCfile()  # Read *_functions.c
    reader.read_literalsHFile()  # Read *_literals.h

    #################################
    # Builders
    #################################

    # Builder for the init pb
    builder_init_pb = None
    if init_pb:
        builder_init_pb = factory(reader_init)

        builder_init_pb.buildVariables()
        builder_init_pb.buildEquations()
        builder_init_pb.buildWarnings()
        builder_init_pb.buildCallFunctions()
        builder_init_pb.prepareForPrint()

    # Builder for the dynamic pb
    builder = factory(reader)

    builder.buildVariables()

    # In order to build C++ methods getTypeVariable(...) and defineElements(...)
    builder.buildElements()
Ejemplo n.º 4
0
 def instruction(self, items):
     items = [x for x in items if not isinstance(x, Token)]  # Ignore WS
     operation = items[0]
     operands = items[1:]
     return factory(operation, *operands)
Ejemplo n.º 5
0
 def test_log(self):
     x1 = factory.factory('numpy', 'log', 10.0)
     import numpy
     x2 = numpy.log(10.0)
     self.assertEqual(x1, x2)
Ejemplo n.º 6
0
 def test_double(self):
     args = ['double', 2]
     self.assertEqual(factory.factory('__main__', args[0], *args[1:]), 4)
Ejemplo n.º 7
0
from factory import factory

choice = int(input('사이트를 선택해주세요\n1. 백준\n2. 프로그래머스\n입력 : '))
problem_number = input('문제 번호를 입력해주세요 : ')

site = factory(choice, problem_number)

try:
    f = open(site.get_filename(), 'x')
    f.write(site.get_content())
except:
    raise FileExistsError(
        f'이미 [{problem_number}. {site.get_title()}] 파일이 존재합니다!')

f.close()
print(f'[{problem_number}번: {site.get_title()}] 문제의 코드가 생성되었습니다.')