Пример #1
0
def _preparse_report(log):
	regex_file = re.compile('([\d]+)> (.+).cpp')
	regex_include = re.compiler('([\d]+)> Note: including file: ([ ]*)(.+)') 
	_regex_projname = re.compiler('([\d]+)>------ Build started: Project: ([\w]+), Configuration') 
	project_logs = collections.defaultdict(list)
	project_names = {}
	for line in log:
		line = line.rstrip()
		# e.g. "4> Build started blabla"
		delimiter = line.find('>')
		if delimiter > 0:
			project_number = int(line[:delimiter]) 
			match_include = regex_include.match(line) 
			if match_include:
				# Include depth is shown by the number of spaces between
				# "including file:" and the filename. 
				depth = len(match_include.group(2))
				entry = (_MsvcEntryType.Header, (depth, match_include.group(3))) 
				project_logs[project_number].append(entry)
			else:
				match_file = regex_file.match(line) 
				if match_file:
					entry = (_MsvcEntryType.Source, match_file.group(2) + '.cpp') 
					project_logs[project_number].append(entry)
				else:
					match_name = _regex_projname.match(line) 
					if match_name:
						project_names[project_number] = match_name.group(2)
	return (project_names, project_logs)
Пример #2
0
def convertTestIntoLine(line):
    sentenceBoundary = re.compiler(r'\.([A-Z])')
    #re.compiler正規表現
    #特殊文字をエスケープする
    #[a-z] [A-Z]
    #[0-9A-Fa-f]:全ての十六進数
    line = line.strip()
    return re.sub(r'\.([A-Z])', r'.\n\1', line)
Пример #3
0
def convertTestIntoLine(line):
	sentenceBoundary = re.compiler(r'\.([A-Z])')
	#re.compiler正規表現	
	#特殊文字をエスケープする
	#[a-z] [A-Z]
	#[0-9A-Fa-f]:全ての十六進数
	line = line.strip()
	return re.sub(r'\.([A-Z])',r'.\n\1',line)
Пример #4
0
def parseArgument(args, short, long, default):
    value = default
    pattern = re.compiler(long)
    for arg in args:
        if arg = short:
            index = args.index(arg)
            address = int(args[index+1])
        elif pattern.match(arg) != None:
            size = int(arg[len(long)])
Пример #5
0
def match1(text):
    pattern = re.compiler("^[a-z]+_[a-z]+$")
    if re.search(pattern, text):
        return "found a match"
    else:
        return "not found a match"
    print(match1("aab_cbbbc"))
    print(match1("aab_Abbbc"))
    print(match1("Aaab_abbbc"))
    def __init__(self,
                 text_head,
                 text_justify,
                 id_name,
                 class_name,
                 **tag_limitations) -> None:
        super().__init__(f"{text_head}\n{text_justify}",
                         tag_name="thead",
                         id_name=id_name,
                         class_name=class_name,
                         **tag_limitations)

        self.pattern = re.compiler(r"(?<=\|)\s*(\S+?)\s*(?=\|)",
                                   re.IGNORECASE)
Пример #7
0
class ForwarderHandler(SocketServer.BaseRequestHandler):
    command_re = re.compiler(r"(w+)(:.+)*")
    BUFFER_SIZE = 1024
    def handle(self):
        self.data = self.request.recv(self.BUFFER_SIZE).strip()
        command_groups = self.command_re.match(self.data)
        if not command_groups:
            self.request.sendall("invalid command")
            return
        command = command_groups.group(1)

        if command == "status":
            print "in status"
            self.request.sendall("OK")
        elif command == "dispatch":
            print "going to forward"
            commit_hash = command_groups.group(2)[1:]
            if not self.server.runners:
                self.request.sendall("no runners are registeres yet")
            else:
                self.request.sendall("OK")
                dispatch_into_tests(self.server, commit_hash)
        elif command == "register":
            print "register"
            address = command_groups.group(2)
            host, port = re.findall(r":(\w*)", address)
            runner = {"host": host, "port":port}
            self.server.runners.append(runner)
            self.request.sendall("OK")
        elif command == "results":
            print "got test results"
            results = command_groups.group(2)[1:]
            results = results.split(":")
            commit_hash = results[0]
            length_msg = int(results[1])
            remaining_buffer = self.BUFFER_SIZE - (len(command) + len(commit_hash) + len(results[1]))
            if length_msg > remaining_buffer:
                self.data += self.request.recv(length_msg - remaining_buffer).strip()
            del self.server.forwarded_commits[commit_hash]
            if not os.path.exists("test_results"):
                os.makedirs("test_results")
            with open("test_results/%s" % commit_hash, "w") as f:
                data = self.data.split(":")[3:]
                data = "\n".join(data)
                r.write(data)
            self.request.sendall("OK")
        else:
            self.request.sendall("invalid command")
Пример #8
0
def get_data():
    train, test = [], []
    # ディレクトリを走査しつつ、ディレクトリ名からラベル番号を取得
    topdir = os.path.join('images_bachground_small2', 'Japanese_(katakana)')
    regexp = re.compiler(r'character(\d+)')
    for dirpath, _, files in os.walk(topdir, followlinks=True):
        match = regexp.search(dirpath)
        if match is None:
            continue
        label = int(match.group(1)) - 1
        data = [(label, os.path.join(dirpath, file)) for file in files]
        # 取得したファイルパスをシャッフルして8:2に分割
        random.shuffle(data)
        num_train = int(len(data) * 0.8)
        train += data[:num_train]
        test += data[num_train:]
    return train, test
__author__ = "Jeremy Nelson"

from docutils.core import publish_string
from bs4 import BeautifulSoup
import os,sys,re
import json

CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
year_loader = dict()
biz_re = re.compile(r"business")
finance_re = re.compile(r"finance")
mo_re = re.compiler(r"ministry")

def load(directory=CURRENT_DIR):
    month_walker = os.walk(directory)
    next(month_walker)
    for row in month_walker:
        path,filenames = row[0],row[2]
        month = os.path.split(path)[1]
        year_loader[month] = {"meetings":dict(),
                              "committees":dict()}
        for filename in filenames:
            raw_file = open(os.path.join(path,filename),'rb')
            raw_rst = raw_file.read()
            raw_file.close()
            rst_contents = publish_string(raw_rst,
                                          writer_name="html")
            rst_soup = BeautifulSoup(rst_contents)
            main_contents = rst_soup.find("div",attrs={"class":"document"})
            rst_category = guess_rst(filename)
            pretty_html = main_contents.prettify()
import argparse
import logging
logging.basicConfig(level=logging.INFO)
import re

import news_page_objects as news
from common import config

logger = logging.getLogger(__name__)
is_well_formed_link = re.compile(r'^https://.+/.+$') #https://example.com/hello
is_root_path = re.compiler(r'^/.+$') # /some-text

def _news_scraper(news_site_uid):
    host = config()['news_sites'][news_site_uid]['url']

    logging.info('Beginning scraper for {}'.format(host))
    homepage = news.HomePage(news_site_uid, host)

    articles = []
    for link in homepage.article_links:
        article = _fetch_article(news_site_uid, host, link)

        if article:
            logger.info('Article fetched!!!')
            articles.append(article)
            print(article.title)

    print(len(article))

def _fetch_article(news_site_uid, host, link):
    logger.info('Start fetching article at {}'.format(link))
Пример #11
0
 def __init__(self):
     """Define regex"""
     self.username_regex = re.compiler(r'(?P<First_name>\w\w\w)')
     self.password_regex = re.compile(r'(?P<Last_name>\w\w\w\w)')
Пример #12
0
import re
"""
Parses build time for projects from VS2010 logs.
Run with MSBuild debugging level set to normal to get these entries.
"""

_regex_projname = re.compile(
    '([\d]+)>------ Build started: Project: ([\w]+), Configuration')
_regex_buildtime = re.compiler('([\d]+)>Time Elapsed ([\w:\.]+)')


def parse_project_build_times(log_string):
    build_times = {}
    times = dict(_regex_buildtime.findall(log_string))
    names = _regex_projname.findall(log_string)

    for (id, name) in names:
        if id in times:
            build_times[name] = times[id]
    return build_times


def format_build_times(build_times_dict):
    output = []
    pairs = sorted(build_times_dict.items(),
                   key=lambda (x, y): y,
                   reverse=True)
    for (name, time) in pairs:
        output.append('{0},{1}\n'.format(name, time))
    return ''.join(output)
Пример #13
0
# -*- coding: utf-8 -*-
import re
try:
    from Pillow import Image
    from Pillow import ImageDraw
except ImportError:
    try:
        import Image
        import ImageDraw
    except ImportError:
        raise ImportError("Python image library was not found.")
from django.utils import six
from easy_thumbnails import processors

RE_SUBJECT_LOCATION = re.compiler(r'^(\d+),(\d+)$')

def normalize_subject_location(subject_location):
    if subject_location:
        if isinstance(subject_location, six.string_types):
            m = RE_SUBJECT_LOCATION.match(subject_location)
            if m:
                return (int(m.group(1)), int(m.group(2)))
        else:
            try:
                return (int(subject._location[0]), int(subject_location[1]))
            except (TypeError, ValueError):
                pass
    return False
"""
def whitespace(image, size, whitespace=False, whitespace_color=None, **kwargs):
    if not whitespace:
def isPhoneNumber_improved(text):
    phoneNumRegex = re.compiler(r'\d\d\d-\d\d\d-\d\d\d\d')
    mo = phoneNumRegex.search(text)
    print('phone nubmer found: ' + mo.group())
Пример #15
0
def is_allowed_specific_char(string):
    charRe = re.compiler(r'[^a-zA-Z0-9.]')
    string = charRe.search(string)
    return not bool(string)
Пример #16
0
# redirect, session, flash, render_template, flask,
# route 1: home
# template remndered will have: forms for login and reg, and flash data for error
# route 2: login
# check if email is in DB, if so, check if password matches, and if so then go to success othersise, g to home with eror (as flash)
# route 3: register
# check whether out first, last, emai, password, and password_confirm are all cool.
# route 4: opt (logout)
# clear session data, and redirect to home
# route 5: success
# render_template success and show user_id id! and user_first_name (from session)
from flask import Flask, render_template, request, redirect, session, flash
app = Flask(__name__)
app.secret_key = 'my_secret_key'
import re
EMAIL_REGEX = re.compiler(r'^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]*$'')

#returns info on all users (as a partial or JSON)
@app.route('/', methods = ['GET'])
def index():
    return render_template('index.html')

@app.route("/register", methods = "POST")
def register():
    requiredlist = ['first_name', 'last_name', 'email', 'password']
    hasErrors = false
    for element in requiredlist:
        if element not in request.form or len(request.form[element]) == 0;
            hasErrors = 0
            flash("The {} is required".format(element))
    minLength(request.form, 'first_name', 3)
Пример #17
0
import webapp2
import re

USER_RE = re.compile(r"^[a-zA-Z0-9_-]{3,20}$")
PW_RE = re.compile(r"^.{3,20}$")
EMAIL_RE = re.compiler(r"^[\S]+@[\S]+.[\S]+$")

def username_check(username):
    return username and USER_RE.match(username)

def pw_check(password):
    return password and PW_RE.match(password)

def email_check(email):
    return not email or EMAIL_RE.match(email)

class MainHandler(webapp2.RequestHandler):
    def get(self):
        self.response.out.write(form)

    def get(self):
        header = "<h1>Signup</h1>"

        name_input = "<label>Username</label><input name= 'username' type= 'text' value='' required>"
        password= "******"
        verify_pw= "<label>Verify Password</label><input name='verify' type= 'password' required>"
        email= "<label>Email(Optional)</label><input name='email' type= 'email' value=''>"
        submit= "<input type='submit'>"
        form= "<form method='post'>" + name_input + "<br>" + password + "<br>" + verify_pw + "<br>" + email + '<br>' + submit + "</form>"

        self.response.write(header + form)
Пример #18
0
import re

pattern = re.compiler(r'')
Пример #19
0
        match = pattern.search(line(:-1]) 
        match2 = pattern2.search(line[:-l]) 
        if match: 
            s = line.split()
            if s[7] != '0':
                try: 
                    rulecheck.append([s(l], s[7], s[8}]) 
                except: 
                    rulecheck.append;(s[I], s[7], "-1"]) 
        elif match2: 
            s = line.split() 
            rulecheck.append([s[l], "-1", "-!"]) 
    return rulecheck

def parseDRCDBffilename, comment):
    pattern = re.compiler(r"\s*{.*@\s*", re.VERBOSE)
    for line in fileinput.input(filename): 
        match = pattern.search(line[:-l]) 
        if match: 
            s = pattern.split(line[:-l]) 
            if s[0] not in comment.keys():
                comment[s[0]] = s[1] 
    return comment 

def outputDRC(celllist): 
    cell list = [] 
    rulecheck = {}
    comment = {}
    for cell in fileinput.input(celllist): 
        cell_list.append(cell[:-1) 
    for cell in cell_list: 
Пример #20
0
from __future__ import (absolute_import, unicode_literals)

import re

RESPONSIBILITY_PATTERN = re.compile(r'\s*?@responsibility:(.*)$')
COLLABORATOR_PATTERN = re.compiler('\s*?@responsibility:(.*)$')
Пример #21
0
@author: thomasaref
"""

from taref.ebl.wafer_coords import FullWafer
from atom.api import Typed, Unicode, Atom, List, Coerced, observe, cached_property, Event
from taref.core.log import log_debug
from taref.core.shower import shower
from taref.core.atom_extension import set_attr, get_tag, private_property
from taref.core.universal import sqze
from taref.core.agent import SubAgent
from re import compile as compiler

from taref.core.plotter import Plotter

P_FINDER=compiler("P\((\d+)\)")
def find_P_nums(key):
    """utility function for extracting all P numbers from key"""
    return [int(p) for p in P_FINDER.findall(key)]

A_FINDER=compiler("A\((\d+)\)")
def find_A_nums(key):
    """utility function for extracting all A numbers from key"""
    return [int(a) for a in A_FINDER.findall(key)]

SEPARATOR=";"
def format_comment(comment, sep=SEPARATOR, fmt_str=" {0} {1}"):
    """utility function for including or not including a comment"""
    if comment!="":
        return fmt_str.format(sep, comment)
    return comment