示例#1
0
app = App(database_url=os.environ.get('DATABASE_URL'),
          use_uuid=True,
          mapping=[
              ('apn', 'apn', str, None), ('OBJECTID', 'object_id', int, None),
              ('licenseNumber', 'license_number', str, None),
              ('category', '', str, None), ('milestone', '', str, None),
              ('tier', '', str, None), ('status', '', str, None),
              ('issueDate', 'issue_date', date, Transform.utc_str_to_utc_date),
              ('expirationDate', 'expiration_date', date,
               Transform.utc_str_to_utc_date), ('address', '', str, None),
              ('ownerName', 'owner_name', str, None),
              ('ownerAddress1', 'owner_address_1', str, None),
              ('ownerAddress2', 'owner_address_2', str, None),
              ('ownerCity', 'owner_city', str, None),
              ('ownerState', 'owner_state', str, None),
              ('ownerZip', 'owner_zip', str, None),
              ('ownerPhone', 'owner_phone', str,
               Transform.hyphenate_phone_number),
              ('ownerEmail', 'owner_email', str, None),
              ('applicantName', 'applicant_name', str, None),
              ('applicantAddress1', 'applicant_address_1', str, None),
              ('applicantAddress2', 'applicant_address_2', str, None),
              ('applicantCity', 'applicant_city', str, None),
              ('applicantState', 'applicant_state', str, None),
              ('applicantZip', 'applicant_zip', str, None),
              ('applicantPhone', 'applicant_phone', str,
               Transform.hyphenate_phone_number),
              ('applicantEmail', 'applicant_email', str, None),
              ('licensedUnits', 'licensed_units', int, None),
              ('ward', '', str, None),
              ('neighborhoodDesc', 'neighborhood_desc', str, None),
              ('communityDesc', 'community_desc', str, None),
              ('policePrecinct', 'police_precinct', str, None),
              ('latitude', '', float, None), ('longitude', '', float, None),
              ('xWebMercator', 'x_web_mercator', float, None),
              ('yWebMercator', 'y_web_mercator', float, None)
          ])
示例#2
0
ascii_char = list("$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/|()1{}[]?-_+~<>i!lI;:,\"^`'. ")


def get_char(r, g, b, alpha=256):
    if alpha == 0:
        return ' '
    length = len(ascii_char)
    gray = int(0.2126 * r + 0.7152 * g + 0.0722 * b)

    unit = (256.0 + 1) / length
    return ascii_char[int(gray / unit)]


if __name__ == '__main__':
    image_file = App.resource_file("/opencv/green-spiral.jpg")
    im = Image.open(image_file)
    pix = im.load()

    ims = Image.new("RGB", (im.width,im.height), (255, 255, 255))
    dr = ImageDraw.Draw(ims)
    font = ImageFont.truetype(os.path.join("fonts", "msyh.ttf"), 10)

    txt = ""
    for i in range(im.height):
        for j in range(im.width):
            char = get_char(*im.getpixel((j,i)))
            txt += char
            dr.text((j,i),char, pix[j, i], font)
        txt += '\n'
    with open("output.txt", 'w') as f:
示例#3
0

def load_dict(file):
    """英文字典/usr/share/dict"""
    englist_dic = []
    with open(file, 'r', encoding='UTF-8') as ff:
        for line in ff.readlines():
            englist_dic.append(line.strip())

    return tuple(englist_dic)


if __name__ == "__main__":
    """由于都是相对较小的文件因此直接进行统计"""

    endict = load_dict(App.resource_file("linux.words"))
    print("englis dic len:", len(endict))
    count_dict = {}
    for dirpath, dirname, filenames in os.walk(u"C:\edocuments"):
        for filepath in filenames:
            f_n = os.path.join(dirpath, filepath)
            print("consume file =>", f_n)
            try:
                f_content = ''
                with open(f_n, 'r', encoding='UTF-8') as ff:
                    for line in ff.readlines():
                        f_content += line

                # 文章字符串前期处理

                f_content = trunNonalpha(f_content.lower())
示例#4
0
from src import App

app = App()
app.start()
示例#5
0
def run_app():
    App.MyMainApp().run()
示例#6
0
# coding:UTF-8

import numpy as np
from src import App
"""演示从文本中加载数据"""

file_name = App.resource_file("/data/npl/affinity_dataset.txt")
x = np.loadtxt(file_name)

n_samples, n_features = x.shape
print("This dataset has {0} samples and {1} features".format(
    n_samples, n_features))

# The names of the features, for your reference.
features = ["bread", "milk", "cheese", "apples", "bananas"]

# First, how many rows contain our premise: that a person is buying apples
num_apple_purchases = 0
for sample in x:
    if sample[3] == 1:  # This person bought Apples
        num_apple_purchases += 1
print("{0} people bought Apples".format(num_apple_purchases))
示例#7
0
# coding:UTF-8
# python3.x
"""Imagge是pillow库中一个非常重要的模块,提供了大量用于图像处理的方法
"""
from PIL import Image

from src import App

image_file = App.resource_file("/opencv/green-spiral.jpg")

im = Image.open(image_file)

# 图像缩放
# im = im.resize((100,100))
# im.show()

#
# 图像保存
im.save(App.temp__file("/green-spiral.jpg"))

#逆时针旋转90度
im = im.rotate(90)
im.show()
#逆时针旋转180度
im = im.transpose(Image.ROTATE_180)
im.show()
#水平翻转
im = im.transpose(Image.FLIP_LEFT_RIGHT)
im.show()
#垂直翻转
im = im.transpose(Image.FLIP_TOP_BOTTOM)
示例#8
0
from src import App
from src.dataloader import get_questions

buffer = 64
images_path = "images"

canvas_color = "blue"
sidebar_color = "medium blue"

window_geometry = [1024, 600]
window_title = "Geografia do Milhão"

app = App(window_title, window_geometry, images_path, buffer)
app.run(canvas_color, sidebar_color, get_questions())
示例#9
0
# coding:UTF-8

import cv2
from src import App

img_file = App.resource_file("/opencv/timg.jpg")
im = cv2.imread(img_file, 0)

sobx = cv2.CreateImage(cv2.GetSize(im), cv2.IPL_DEPTH_16S, 1)
#Sobel with x-order=1
cv2.Sobel(im, sobx, 1, 0, 3)

soby = cv2.CreateImage(cv2.GetSize(im), cv2.IPL_DEPTH_16S, 1)
#Sobel withy-oder=1
cv2.Sobel(im, soby, 0, 1, 3)

cv2.Abs(sobx, sobx)
cv2.Abs(soby, soby)

result = cv2.CloneImage(im)
#Add the two results together.
cv2.Add(sobx, soby, result)

cv2.Threshold(result, result, 100, 255, cv2.CV_THRESH_BINARY_INV)

cv2.ShowImage('Image', im)
cv2.ShowImage('Result', result)

cv2.WaitKey(0)
示例#10
0
def run():
    log = App.logger(__name__)
    log.info("process is running")
示例#11
0
 def __init__(self, name):
     threading.Thread.__init__(self, name=name)
     self.log = App.logger(__name__)
示例#12
0
from src import App

app = App(width=500, height=500, device_id=1)
# app = App(fullscreen=True)
示例#13
0
# coding:UTF-8
# python3.x
"""Imagge是pillow库中一个非常重要的模块,提供了大量用于图像处理的方法
"""
from PIL import ImageGrab

from src import App

image_file = App.resource_file("/temp/test.jpg")

# 获取屏幕指定区域的图像
im = ImageGrab.grab((0, 0, 100, 200))
im.show()

# 或全屏截图
im = ImageGrab.grab()
im.show()
示例#14
0
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

"""
from kivy.config import Config
from src import App

if __name__ in ('__main__', '__android__'):
    # Go fullscreen. # FixMe: On android status bar still re-appears.
    Config.set('graphics', 'fullscreen', 'auto')
    Config.set('graphics', 'borderless', 1)
    Config.set('graphics', 'window_state', 'maximized')
    Config.write()
    App().run()
示例#15
0
# coding:utf-8

import pandas as pd
from src import App
"""写入文件"""

# 写入excel
df = pd.read_excel(App.resource_file("data/excel-comp-sheetdata.xlsx"))

# 读取全部数据
all_data = pd.DataFrame(df)
print(all_data.loc[14, 'name'])
all_data.loc[14, 'name'] = 'McDermott PLCA'
all_data.to_excel('C:\\Users\\Administrator\\Desktop\\1.xlsx',
                  header=True,
                  index=False)
示例#16
0
#!/usr/bin/python
# coding:utf-8


from src.base.logger import ThreadProcess,process
from src import App

if __name__ == "__main__":
    log = App.logger(__name__)
    log.info("info")
    log.debug("debug")
    log.error("error")
    process.run()

    # 事实证明logging模块是多线程安全的
    for i in range(50):
        ThreadProcess.ThreadProcess("Thread" + str(i)).start()
示例#17
0
    canvas[:, :, :] = 255
    new_image = Image.fromarray(canvas)
    draw = ImageDraw.Draw(new_image)

    # 创建绘制对象
    font = ImageFont.truetype("consola.ttf", 10, encoding="unic")
    char_table = list("$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/|()1{}[]?-_+~<>i!lI;:,\"^`'. ")
    # font = ImageFont.truetype('simsun.ttc', 10)
    # char_table = list(u'新年快乐')

    # 开始绘制
    pix_count = 0
    table_len = len(char_table)
    for y in range(height):
        for x in range(width):
            if x % sample_step == 0 and y % sample_step == 0:
                draw.text((x * scale, y * scale), char_table[pix_count % table_len], pix[x, y], font)
                pix_count += 1

    # 保存
    if dst_img_file_path is not None:
        new_image.save(dst_img_file_path)

    print("used time : %d second, pix_count : %d" % ((int(time.time()) - start_time), pix_count))
    print(pix_count)
    new_image.show()

if __name__ == '__main__':
    image_file = App.resource_file("/img/wm.png")
    temp_file = App.temp_file("wm.png")
happyNewYear(image_file, temp_file)
示例#18
0
keys_and_emojis_file = "keys_and_emojis.json"

# Default: Configuração do programa.
default_settings = {
    "clipboard": False,
    "master_key": ["insert"]
}

# Default: Teclas e emojis.
default_keys_and_emojis = {
    "z": "( ͡° ͜ʖ ͡°)",
    "x": "¯\\_(ツ)_/¯",
    "c": "(^o^)丿",
    "v": "(づ。◕‿‿◕。)づ",
    "b": "(づ ̄ ³ ̄)づ",
    "n": "(ㆆ_ㆆ)",
    "m": "(っ^▿^)"
}

# Atualiza as configurações, teclas e emojis.
settings = update_data_from(settings_file, default_settings)
keys_and_emojis = update_data_from(keys_and_emojis_file, default_keys_and_emojis)

# Inicializa o aplicativo.
app = App(settings["master_key"], settings["clipboard"], keys_and_emojis)
app.run()

# Espera até que o usuário pressione alguma tecla para encerrar o programa.
input("Press any key to close.")
app.stop()