Beispiel #1
0
        def handle(tag, *args, **keywords):

            # first try filling tag with page attributes
            if hasattr(self, tag):
                attr = getattr(self, tag)
                if callable(attr):
                    repl = attr(self, *args, **keywords)
                else:
                    repl = attr
                return fill('<dz:','>', repl, handle)

            # if that doesn't work look for an app helper
            elif tag in system.app.helpers:
                helper = system.app.helpers[tag]

            # if that doesn't work look for a system helper
            elif tag in system.helpers:
                helper = system.helpers[tag]

            # if that doesn't work look in the helpers module
            elif tag in helpers.__dict__ and callable(helpers.__dict__[tag]):
                """call functions in a module or module-like object"""
                helper = helpers.__dict__[tag]

            else:
                helper = None

            if helper:
                if callable(helper):
                    repl = helper(*args, **keywords)
                else:
                    repl = helper

                return fill('<dz:','>', repl, handle)
Beispiel #2
0
        def handle(tag, *args, **keywords):

            # first try filling tag with page attributes
            if hasattr(self, tag):
                attr = getattr(self, tag)
                if callable(attr):
                    repl = attr(self, *args, **keywords)
                else:
                    repl = attr
                return fill('<dz:', '>', repl, handle)

            # if that doesn't work look for an app helper
            elif tag in system.app.helpers:
                helper = system.app.helpers[tag]

            # if that doesn't work look for a system helper
            elif tag in system.helpers:
                helper = system.helpers[tag]

            # if that doesn't work look in the helpers module
            elif tag in helpers.__dict__ and callable(helpers.__dict__[tag]):
                """call functions in a module or module-like object"""
                helper = helpers.__dict__[tag]

            else:
                helper = None

            if helper:
                if callable(helper):
                    repl = helper(*args, **keywords)
                else:
                    repl = helper

                return fill('<dz:', '>', repl, handle)
Beispiel #3
0
 def colors_click(self, number=None):
     assert number, "CLICK ERROR!"
     if self.wined:
         return
     if number in self.COLORS.keys():
         fill.fill(self.table, number, x=0, y=0)
         self.table.draw(self.screen, BLOCK_COLORS)
         self.wined = self.win()
     self.show()
Beispiel #4
0
        def handle(tag,*args,**keywords):
            if hasattr(self, tag):
                attr = getattr(self, tag)
                if callable(attr):
                    repl = attr(self, *args, **keywords)
                else:
                    repl = attr
                return fill('<dz:','>', repl, handle)

            if tag in helpers.__dict__ and callable(helpers.__dict__[tag]):
                """call functions in a module or module-like object"""
                helper = helpers.__dict__[tag]
                return fill('<dz:','>', helper(*args, **keywords), handle)
Beispiel #5
0
    def render(self):

        def handle(tag,*args,**keywords):
            if hasattr(self, tag):
                attr = getattr(self, tag)
                if callable(attr):
                    repl = attr(self, *args, **keywords)
                else:
                    repl = attr
                return fill('<dz:','>', repl, handle)

            if tag in helpers.__dict__ and callable(helpers.__dict__[tag]):
                """call functions in a module or module-like object"""
                helper = helpers.__dict__[tag]
                return fill('<dz:','>', helper(*args, **keywords), handle)

        def set_setting(thing, name):
            if thing=='template':
                self.template = name
            elif thing=='app_title':
                self.app_title = name
            return '<!-- %s set to "%s" -->' % (thing, name)

        def render_snippet(system_snippet, page_snippet):
            return '\n'.join(system_snippet.union(set([page_snippet])))


        DEFAULT_TEMPLATE = os.path.join(system.root,'themes','default','default.html')

        self.content = fill('<dz:set_','>',self.content,set_setting)

        self.js   = render_snippet(system.js, self.js)
        self.css  = render_snippet(system.css, self.css)
        self.head = render_snippet(system.head, self.head)
        self.tail = render_snippet(system.tail, self.tail)

        template_pathname = system.theme_path 
        if template_pathname:
            template_filename = os.path.join(template_pathname, self.template+'.html')
            if not os.path.exists(template_filename):
                if not self.template in ['index','content']:
                    log.logger.warning('template missing (%s)' % (template_filename))
                template_filename = os.path.join(template_pathname, 'default.html')
        self.tpl = template_pathname and tools.load(template_filename) or tools.load(DEFAULT_TEMPLATE)

        content = fill('<dz:','>',self.tpl,handle)
        if self.callback:
            content = fill('{{','}}',content,self.callback)

        return HTMLResponse(content)
Beispiel #6
0
def fill_data(datas, method='lgb'):
    """
    Fill the missing data.

    :param datas: a list of data frame with missing values to be filled
    :param method: filling method
    :return: a list of data with filled values
    """

    filled = []
    black_list, fill_targets = settings.fill_data_black_list, settings.fill_data_fill_targets
    fill_predictors = [
        f for f in datas[0].columns if f not in black_list + fill_targets
    ]
    for data in datas:
        filled.append(fill.fill(data, method, fill_predictors, fill_targets))
    print('    NA filled.')
    return filled
        original_img = Image.open(in_file)

        # 元画像の大きさを保存しておく
        original_width = original_img.size[0]
        original_height = original_img.size[1]
        original_img = np.asarray(original_img)

        # 所定の大きさにresize
        resized_img = to_square(original_img, args.size)

        # U-Netを用いてsegentation(確率値を出力)
        probs = predict_img(net, resized_img, args.gpu)

        # もとの大きさに戻す
        probs_resized = from_square(probs, (original_height, original_width))

        # ノイズ除去 & 二値化
        dst_img = remove_noise(probs_resized,
                               (original_height, original_width), original_img)
        dst_img = (dst_img * 255).astype(np.uint8)

        # 真ん中を穴埋め
        if "b83d1d77935b6cfd44105b54600ffc4b6bd82de57dec65571bcb117fa8398ba3" in in_file:
            print("zzzzzzzzzzzzzzzzzz")
        else:
            dst_img = fill(dst_img)

        # 結果を画像として保存
        result = Image.fromarray(dst_img)
        result.save(out_file)
Beispiel #8
0
        sys.exit(1)
    if result == 0:
        print(
            "Pipeline has not been executed today. Running now with new candidate data..."
        )
        return False

    print(
        "Pipeline has already been run for today. Live data with new candidate info will be pulled tomorrow."
    )
    return True


if __name__ == "__main__":
    try:
        cname = sys.argv[1]
    except:
        print("Error: please pass in a candidate name")
        sys.exit(1)

    insert_cand(cname)
    conn.commit()
    print("Candidate table successfully updated.")
    sleep(5)
    fill_pipeline.fill("today")
    sleep(5)
    print(
        "Finished updating query table. Updating all other tables accordingly."
    )
    calc.update_all()
Beispiel #9
0
def format_email(body):
    logo_url = system.config.get('mail','logo',system.uri + '/images/email_logo.png')
    return fill('{{','}}',email_body,dict(logo_url=logo_url,message=body).get)
Beispiel #10
0
#!/usr/bin/env python
# Use this script to fill a Adyen test account with some random transaction data using the SOAP API

import fill

wsUser = '******'		# Create a new "system" or "ws" user in Adyen backoffice
wsPassword = '******'			# Password: min 8 chars, should contain number(s)
wsAccount = '________'				# Merchant Account
numTransactions = 50				# Number of transactions to fill

fill.fill(wsUser,wsPassword,wsAccount,numTransactions)

Beispiel #11
0
    def render(self):
        def handle(tag, *args, **keywords):

            # first try filling tag with page attributes
            if hasattr(self, tag):
                attr = getattr(self, tag)
                if callable(attr):
                    repl = attr(self, *args, **keywords)
                else:
                    repl = attr
                return fill('<dz:', '>', repl, handle)

            # if that doesn't work look for an app helper
            elif tag in system.app.helpers:
                helper = system.app.helpers[tag]

            # if that doesn't work look for a system helper
            elif tag in system.helpers:
                helper = system.helpers[tag]

            # if that doesn't work look in the helpers module
            elif tag in helpers.__dict__ and callable(helpers.__dict__[tag]):
                """call functions in a module or module-like object"""
                helper = helpers.__dict__[tag]

            else:
                helper = None

            if helper:
                if callable(helper):
                    repl = helper(*args, **keywords)
                else:
                    repl = helper

                return fill('<dz:', '>', repl, handle)

        def set_setting(thing, name):
            if thing == 'template':
                self.template = name
            elif thing == 'app_title':
                self.app_title = name
            return '<!-- %s set to "%s" -->' % (thing, name)

        def render_snippet(system_snippet, page_snippet):
            return '\n'.join(system_snippet | OrderedSet([page_snippet]))

        def render_script_tags(system_scripts, page_scripts):
            scripts = system_scripts | page_scripts
            h = scripts and '\n        <!-- Page Specific Scripts -->\n' or ''
            c = '\n'.join(
                '        <script type="text/javascript" src="{}"></script>'.
                format(t) for t in scripts)
            t = scripts and '\n\n' or ''
            return h + c + t

        def render_style_sheets(system_style_sheets, page_style_sheets):
            sheets = system_style_sheets | page_style_sheets
            h = sheets and '\n        <!-- Page Specific Styles -->\n' or ''
            c = '\n'.join(
                '        <link rel="stylesheet" type="text/css" href="{}">'.
                format(t) for t in sheets)
            t = sheets and '\n\n' or ''
            return h + c + t

        DEFAULT_TEMPLATE = os.path.join(system.root, 'themes', 'default',
                                        'default.html')

        self.theme = self.theme or system.app.theme or user.theme or system.theme
        if self.theme != system.theme:
            system.set_theme(self.theme)

        self.content = fill('<dz:set_', '>', self.content, set_setting)

        self.styles = render_style_sheets(system.styles, self.styles)
        self.css = render_snippet(system.css, self.css)
        self.libs = render_script_tags(system.libs, self.libs)
        self.js = render_snippet(system.js, self.js)
        self.head = render_snippet(system.head, self.head)
        self.tail = render_snippet(system.tail, self.tail)

        if len(route) > 1:
            breadcrumb = link_to(system.app.title, '/' + system.app.name)
        else:
            breadcrumb = ''

        template_pathname = system.theme_path
        if template_pathname:
            template_filename = os.path.join(template_pathname,
                                             self.template + '.html')
            if not os.path.exists(template_filename):
                if not self.template in ['index', 'content']:
                    log.logger.warning('template missing (%s)' %
                                       (template_filename))
                template_filename = os.path.join(template_pathname,
                                                 'default.html')
        self.tpl = template_pathname and tools.load(
            template_filename) or tools.load(DEFAULT_TEMPLATE)

        page_header = self.render_header()
        save_content = self.content
        self.content = page_header + self.content
        save_title = self.title
        del self.title
        content = fill('<dz:', '>', self.tpl, handle)
        self.title = save_title
        self.content = save_content
        if self.callback:
            content = fill('{{', '}}', content, self.callback)

        return HTMLResponse(content)
import fill
import array
a = array.array('I')
a.append(1)
a.append(1)
a.append(3)
a.append(2)
a.append(2)
a.append(2)
a.append(2)
a.append(2)
a.append(2)
a.append(2)
a.append(2)
a.append(2)
print "before", a
b = fill.fill(a, 2, 2, 3, 3, 4278190080)
print "after", b

print "after 2", array.array('I', b)
Beispiel #13
0
import fill
import afiniczne
import open
import filtr

b = input("Podaj ścierzkę do pliku: ")
a = int(
    input(
        "Wybierz operację: \n1)Przekształcenie afiniczne,\n2)Filtracja odchylenia stangardowego,\n3)Otwarcie elementem kołowym,\n4)Wypełnienie dziur.\n"
    ))
#b="onion.png"
#a=2
if (a == 1):
    afiniczne.afiniczne(b)
elif (a == 2):
    c = int(input("Podaj rozmiar maski: "))
    #c=3
    filtr.filtr(b, c)
elif (a == 3):
    c = int(input("Podaj promień: "))
    open.open(b, c)
elif (a == 4):
    fill.fill(b)
else:
    print("błędna cyferka")
Beispiel #14
0
def makeProblem(**kwargs):
    # 8 rngs to make it extremly hard that we get the same one twice (birthday 2^(4*32))
    #  numpys rngs are limited to 32 bits, so use multible to make the randomness more robust.
    defaults = {'w': 120, 'h': 144, 'chunk':12, 'worldW': 648, 'density': 0.02,
                'time': 10000, 'seed': [1234,2345,3456,4567,5678,6789,7890,89011]}
    return fill.fill(kwargs, defaults)
Beispiel #15
0
    def render(self):

        def handle(tag, *args, **keywords):

            # first try filling tag with page attributes
            if hasattr(self, tag):
                attr = getattr(self, tag)
                if callable(attr):
                    repl = attr(self, *args, **keywords)
                else:
                    repl = attr
                return fill('<dz:','>', repl, handle)

            # if that doesn't work look for an app helper
            elif tag in system.app.helpers:
                helper = system.app.helpers[tag]

            # if that doesn't work look for a system helper
            elif tag in system.helpers:
                helper = system.helpers[tag]

            # if that doesn't work look in the helpers module
            elif tag in helpers.__dict__ and callable(helpers.__dict__[tag]):
                """call functions in a module or module-like object"""
                helper = helpers.__dict__[tag]

            else:
                helper = None

            if helper:
                if callable(helper):
                    repl = helper(*args, **keywords)
                else:
                    repl = helper

                return fill('<dz:','>', repl, handle)

                

        def set_setting(thing, name):
            if thing=='template':
                self.template = name
            elif thing=='app_title':
                self.app_title = name
            return '<!-- %s set to "%s" -->' % (thing, name)

        def render_snippet(system_snippet, page_snippet):
            return '\n'.join(system_snippet | OrderedSet([page_snippet]))

        def render_script_tags(system_scripts, page_scripts):
            scripts = system_scripts | page_scripts
            h = scripts and '\n        <!-- Page Specific Scripts -->\n' or ''
            c = '\n'.join('        <script type="text/javascript" src="{}"></script>'.format(t) for t in scripts)
            t = scripts and '\n\n' or ''
            return h + c + t

        def render_style_sheets(system_style_sheets, page_style_sheets):
            sheets = system_style_sheets | page_style_sheets
            h = sheets and '\n        <!-- Page Specific Styles -->\n' or ''
            c = '\n'.join('        <link rel="stylesheet" type="text/css" href="{}">'.format(t) for t in sheets)
            t = sheets and '\n\n' or ''
            return h + c + t

        DEFAULT_TEMPLATE = os.path.join(system.root,'themes','default','default.html')

        self.theme = self.theme or system.app.theme or user.theme or system.theme
        if self.theme != system.theme:
            system.set_theme(self.theme)

        self.content = fill('<dz:set_','>', self.content, set_setting)

        self.styles = render_style_sheets(system.styles, self.styles)
        self.css    = render_snippet(system.css, self.css)
        self.libs   = render_script_tags(system.libs, self.libs)
        self.js     = render_snippet(system.js, self.js)
        self.head   = render_snippet(system.head, self.head)
        self.tail   = render_snippet(system.tail, self.tail)

        if len(route)>1:
            breadcrumb = link_to(system.app.title,'/'+system.app.name)
        else:
            breadcrumb = ''

        template_pathname = system.theme_path
        if template_pathname:
            template_filename = os.path.join(template_pathname, self.template+'.html')
            if not os.path.exists(template_filename):
                if not self.template in ['index','content']:
                    log.logger.warning('template missing (%s)' % (template_filename))
                template_filename = os.path.join(template_pathname, 'default.html')
        self.tpl = template_pathname and tools.load(template_filename) or tools.load(DEFAULT_TEMPLATE)

        page_header = self.render_header()
        save_content = self.content
        self.content = page_header + self.content
        save_title = self.title
        del self.title
        content = fill('<dz:','>', self.tpl, handle)
        self.title = save_title
        self.content = save_content
        if self.callback:
            content = fill('{{','}}', content, self.callback)

        return HTMLResponse(content)