Exemple #1
0
def save(args):
    config = load_config()
    if args.pattern:
        generate(config, args.pattern)
        config.set_type(args.name, args.pattern)
        print("Pattern '{}' saved as type '{}'.".format(args.pattern, args.name))
    else:
        if args.name not in config.types:
            raise ValueError("No type named {}.".format(args.name))
        if confirm("Delete type with name {}?".format(args.name)):
            config.remove_type(args.name)
            print("Type {} deleted.".format(args.name))
    save_config(config)
Exemple #2
0
def gen(args):
    config = load_config()
    if args.pattern:
        password = generate(config, args.pattern)
    else:
        password = generate_from_type(config, args.type)
    process_password(args, config, password)
Exemple #3
0
 def test_ordered(self):
     pattern = "onu{20}n"
     password = generate(Config(), pattern)
     self.assertEqual(len(password), 22)
     try:
         int(password[0])
         int(password[21])
     except ValueError:
         self.fail("Numerals not at expected indices")
Exemple #4
0
def test_file(filename, print_exception=True):
    """
    测试filename代码的编译与执行
    :param filename:
    :param print_exception: 是否打印异常
    :return: 是否正确编译与执行
    """
    output_filename = filename.split('.')[0] + ".ll"

    if print_exception:
        generate_result = generate(input_filename=filename,
                                   output_filename=output_filename)
    else:
        try:
            generate_result = generate(input_filename=filename,
                                       output_filename=output_filename)
        except Exception:
            traceback.print_exc()
            print("generate", filename, "failed.")
            return False

    if not generate_result:
        traceback.print_exc()
        print("generate", filename, "failed.")
        return False
    else:
        if print_exception:
            execute_result = execute(output_filename)
        else:
            try:
                execute_result = execute(output_filename)
            except Exception as e:
                print("execute", output_filename, "failed.")
                traceback.print_exc()
                return False

        return True
# -*- coding: utf-8 -*-
# Copyright 2018 Mobicage NV
# NOTICE: THIS FILE HAS BEEN MODIFIED BY MOBICAGE NV IN ACCORDANCE WITH THE APACHE LICENSE VERSION 2.0
# Copyright 2018 GIG Technology NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# @@license_version:1.5@@

import os
os.environ['AUTH_DOMAIN'] = 'gmail.com'    # Do not remove this line
from rogerthat.rpc.calls import service_callback_mapping
from rogerthat.rpc.service import get_service_api_calls
from rogerthat.service.api import friends, messaging
from generator.generator import generate


service_mapping = get_service_api_calls(friends)
service_mapping.update(get_service_api_calls(messaging))
generate(os.path.splitext(os.path.basename(__file__))[0], service_mapping, service_callback_mapping, max_argument_count=1000)
Exemple #6
0
def get_sample_courses():
    conf = get_conf()
    selected_semester = fetch_selected_semester(conf['semester'])
    programmes = fetch_programmes(conf['programme'])
    return fetch_courses(conf['course'], semester=selected_semester[1])


def print_pretty(courses):
    print(reduce((lambda x, y: x + '\n\n' + y), (map((lambda x: str(x)), courses))))


if __name__ == '__main__':
    if False:
        refresh_course(get_conf())

    codes = [ 'CE3006', 'CE4011', 'CE4022', 'CE4023', 'CZ4042', 'CZ4031' ]
    courses = find_courses_from_codes(codes)
    print_pretty(courses)

    for i in range(1, len(courses) + 1):
        result = generate(courses, i)

#
# CE4011
# CE4022
# CE4023
# CZ4042
# CZ4031
# HW0310
# CE3006
#
Exemple #7
0
 def test_descriptor_range_syntax_error(self):
     pattern = "n{10-20"
     with self.assertRaises(ValueError):
         generate(Config(), pattern)
Exemple #8
0
 def test_basic(self):
     pattern = "lunNsxSaAhHbcC"
     password = generate(Config(), pattern)
     self.assertEqual(len(password), 14)
Exemple #9
0
 def wrapper(self, *args, **kwargs):
     func(self, *args, **kwargs)
     self.todo_txt.write(generator.generate(self.todo))
Exemple #10
0
 def test_illegal_descriptor_range(self):
     pattern = "n{20-10}"
     with self.assertRaises(ValueError):
         generate(Config(), pattern)
# Copyright 2017 GIG Technology NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# @@license_version:1.3@@

import os

os.environ['AUTH_DOMAIN'] = 'gmail.com'  # Do not remove this line
from rogerthat.rpc.calls import service_callback_mapping
from rogerthat.rpc.service import get_service_api_calls
from rogerthat.service.api import friends, messaging
from generator.generator import generate

service_mapping = get_service_api_calls(friends)
service_mapping.update(get_service_api_calls(messaging))
generate(os.path.splitext(os.path.basename(__file__))[0],
         service_mapping,
         service_callback_mapping,
         max_argument_count=1000)
Exemple #12
0
    parser = argparse.ArgumentParser()

    parser.add_argument('-x',
                        '--width',
                        type=int,
                        default=640,
                        help='Width of the generated images')
    parser.add_argument('-y',
                        '--height',
                        type=int,
                        default=480,
                        help='Height of the generated images')

    args = parser.parse_args()

    generator = SheetMetalGenerator(args)
    image, mask = generator.generate()

    assert len(image.shape) == 3
    assert image.shape[0] == args.height
    assert image.shape[1] == args.width
    assert image.shape[2] == 3
    assert image.dtype == np.float64

    assert len(mask.shape) == 2
    assert mask.shape[0] == args.height
    assert mask.shape[1] == args.width
    assert mask.dtype == np.float64

    utils.show_image([image, 'Sheet metal'], [mask, 'Specimen mask'])
Exemple #13
0
 def test_range_descriptor(self):
     pattern = "h{5-6}"
     password = generate(Config(), pattern)
     self.assertGreaterEqual(len(password), 5)
     self.assertLessEqual(len(password), 6)
Exemple #14
0
 def test_optional_descriptor(self):
     pattern = "nN?"
     password = generate(Config(), pattern)
     self.assertGreaterEqual(len(password), 1)
     self.assertLessEqual(len(password), 2)
Exemple #15
0
 def test_length_descriptor(self):
     pattern = "a{10}"
     password = generate(Config(), pattern)
     self.assertEqual(len(password), 10)
Exemple #16
0
 def generate_to_file(self):
     """
     Generate tasks to file.
     """
     content = generator.generate(self.todo)
     open(self.file_path(), "w").write(content)
Exemple #17
0
# -*- coding: utf-8 -*-
# Copyright 2017 GIG Technology NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# @@license_version:1.3@@
import os

from generator.generator import generate  # must be first import
from rogerthat.rpc.calls import client_mapping, mapping

generate(
    os.path.splitext(os.path.basename(__file__))[0], mapping, client_mapping)
Exemple #18
0
from generator.generator import (
    generate,
    # generate_models,
    # generate_services,
    # generate_repo,
    generate_api,
)
from generator.components import make_class
from generator.generate_modules import generate_modules
from generator.utils import read_json
from jsonref import JsonRef

if __name__ == "__main__":
    # generate("spec.yaml")
    # generate_models("service_spec.yaml")
    generate("service_spec.yaml")
    # generate_api("service_spec.yaml", "service.yaml")
    # data = {
    #     "type": "class",
    #     "name": "ServiceA",
    #     "inherits": "serviceB",
    #     "decorators": [
    #         "@singleton",
    #     ],
    #     "constructor": {
    #         "decorators": [
    #             "@inject"
    #         ],
    #         "arguments" [
    #             {
    #                 "name": "arg1",
Exemple #19
0
 def test_illegal_character_class(self):
     pattern = "nay"
     with self.assertRaises(ValueError):
         generate(Config(), pattern)
Exemple #20
0
from generator.generator import generate
import sys

if __name__ == '__main__':
    if len(sys.argv) >= 2:
        input_filename = sys.argv[1]
        output_filename = input_filename.strip(".") + ".ll"
        generate(input_filename, output_filename)
    else:
        print("Usage: python main.py (input_filename)")
Exemple #21
0
 def test_illegal_ordered_placement(self):
     pattern = "no"
     with self.assertRaises(ValueError):
         generate(Config(), pattern)
# -*- coding: utf-8 -*-
# Copyright 2017 GIG Technology NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# @@license_version:1.3@@

from generator.generator import generate # must be first import

import os
from rogerthat.rpc.calls import client_mapping, mapping

generate(os.path.splitext(os.path.basename(__file__))[0], mapping, client_mapping)
Exemple #23
0
def backend_data():
    return generator.generate()