コード例 #1
0
 def test_catalog(self):
     test_text_taka_phone = Catalog("Бот, скажи телефон Така")
     self.assertEqual(test_text_taka_phone.get_help(), "+7-905-776-20-86")
     test_text_name = Catalog("Бот, скажи телефон така")
     self.assertEqual(test_text_name.get_help(), "+7-905-776-20-86")
     test_text_name = Catalog("Бот, скажи телефон таки")
     self.assertEqual(test_text_name.get_help(), "+7-905-776-20-86")
コード例 #2
0
def resolve_assortment_tree(assortment):
    cat = Catalog('Наш каталог', [])
    for item in assortment:
        # заглушка, пока фоточки неоткуда грузить
        # item[4] = 'https://megaflowers.ru/pub/bouquet/vse-budet-horosho_m.jpg'
        insert_into_cat(cat, item[5].split(','), Catalog(item[1], \
                        [str(item[3]), item[4]]))
    return cat
コード例 #3
0
ファイル: AF_Book.py プロジェクト: deju/afw_old
    def get(self, book_id):
        user = self.current_user
        AFUser = None
        AFBook = None
        if user is not None:
            AFUser = SuperUser(user)
        #print self.request.uri
        try:
            book = Catalog(_id=book_id)
            AFBook = BaseBook(book)
        except Exception:
            error_info = {
                'des': '未找到该知识谱!',
                'my_exc_info': traceback.format_exc(),
                'reason': ['该知识谱不存在!', '或者该知识谱已经被删除!']
            }
            return self.send_error(status_code=404, **error_info)

        want = self.get_argument("want", "cover")
        if want not in ["cover", "summary", "catalog"]:
            want = "cover"
        title = AFBook.name + ' - 知识谱'
        #print AFBook.node_lib
        node_block_html = create_book_catalog_html(AFBook.node_lib,
                                                   book_id=book._id)
        #print node_block_html
        return self.render("book.html",
                           title=title,
                           user=AFUser,
                           book=AFBook,
                           kind="book",
                           want=want,
                           node_block_html=node_block_html)
コード例 #4
0
 def test_traversal(self):
     cat = Catalog("/tmp/jgoldstone000_image_catalog.csv")
     cat.register_content(
         Path(
             "/Volumes/jgoldstone000/cust/shows/the_goldfinch/AFTER_CALIBRATION/MINI"
         ))
     cat.save()
コード例 #5
0
def given_a_catalog_already_exists(context):
    """Ensure a catalog is already created before testing."""
    if not check_catalog_exists(context):
        try:
            Catalog(context.catalog_name).create()
        except Exception:
            pass
コード例 #6
0
ファイル: AF_EditTool.py プロジェクト: deju/afw_old
def fun_article_delete_src(user,
                           article_id=0,
                           article_type='blog',
                           src_type='code',
                           alias=0,
                           group_id='-1'):

    if article_type not in Article_Type:
        return [1, '不支持当前文章类型!']
    if src_type not in Agree_Src:
        return [1, '不支持当前类型的资源!']

    if article_type == "about":
        AF_Object = About(_id=user.about._id)
    elif article_type == "book-about":
        try:
            book = Catalog(_id=group_id)
            AF_Object = book.about
            limit = book.authority_verify(user)
            if test_auth(limit, A_WRITE) is False:
                return [1, '您无权删除!']
        except Exception, err:
            logging.error(traceback.format_exc())
            logging.error('Catalog not exist, id %s' % group_id)
            return [1, '未找到该知识谱!']
コード例 #7
0
def catalog_init_meta(catalog_id, role):
    """
    Initialize catalog metadata.
    """
    descriptor = registry.lookup(catalog_id)[0]['descriptor']
    catalog = Catalog(catalog_factory, descriptor)
    catalog.init_meta(owner=role)
コード例 #8
0
ファイル: AF_EditTool.py プロジェクト: deju/afw_old
def fun_new_article_pic(user,
                        article_id=0,
                        article_type='blog',
                        title='',
                        url='',
                        thumb='',
                        father_id=0,
                        group_id='-1'):
    isnew = 0
    if article_type not in Article_Type:
        return [1, '不支持当前文章类型!']

    if article_type == "about":
        AF_Object = About(_id=user.about._id)
        isnew = 0
    elif article_type == "book-about":
        try:
            book = Catalog(_id=group_id)
            AF_Object = book.about
            limit = book.authority_verify(user)
            if test_auth(limit, A_WRITE) is False:
                return [1, '您无权修改摘要!']
        except Exception, err:
            logging.error(traceback.format_exc())
            logging.error('Catalog not exist, id %s' % group_id)
            return [1, '未找到该目录!']
コード例 #9
0
 def catalog(self):
     path = '%s/catalog' % self.path
     fields = get_register_fields()
     try:
         return Catalog(path, fields, read_only=True)
     except (DatabaseError, DatabaseOpeningError):
         return None
コード例 #10
0
def GetExistingCatalogRecords(firebase: firebase, documentName: str, documentSemester: str, documentYear: str) -> None:
    """
        Get existing catalog records from database and insert into global collection.

        :param firebase: a firebase connection
        :param documentName: a string representing the catalog document name
        :param documentSemester: a string representation of the catalog academic semester
        :param documentYear: a string representation of the catalog year
    """

    global existingCatalogRecords

    obj_key_list = []

    result = firebase.get('/catalog', None)

    if result is None:
        return

    for i in result.keys():
        obj_key_list.append(i)

    for i in obj_key_list:
        catalog = Catalog()
        catalog.setId(i)
        catalog.setDocumentName(result[i]['document_name'])
        catalog.setSemester(result[i]['semester'])
        catalog.setYear(result[i]['year'])
        existingCatalogRecords.append(catalog)
コード例 #11
0
def catalog_remove_meta(catalog_id, key, value=None):
    """
    Initialize catalog metadata.
    """
    descriptor = registry.lookup(catalog_id)[0]['descriptor']
    catalog = Catalog(catalog_factory, descriptor)
    catalog.remove_meta(key, value)
コード例 #12
0
ファイル: upgrade.py プロジェクト: rafasgj/fpi-project-old
def when_verify_version_of_inexistent_catalog(context):
    """Try to verify the version of an inexistent catalog."""
    context.revision = False
    try:
        context.revision = Catalog("inexistent_catalog").revision
    except Exception as e:
        context.exception = e
コード例 #13
0
def GetCatalogRecords(firebase: firebase) -> None:
    """
        Get existing catalog records from database and insert into global collection.

        :param firebase: a firebase connection

    """

    global catalogs
    global catalogId

    obj_key_list = []

    result = firebase.get('/catalog', None)

    if result is None:
        return

    for i in result.keys():
        obj_key_list.append(i)
        catalogId = i

    for i in obj_key_list:
        catalog = Catalog()
        catalog.setId(i)
        catalog.setDocumentName(result[i]['document_name'])
        catalog.setSemester(result[i]['semester'])
        catalog.setYear(result[i]['year'])
        catalogs.append(catalog)
コード例 #14
0
def catalog_get_meta(catalog_id, key=None):
    """
    Initialize catalog metadata.
    """
    descriptor = registry.lookup(catalog_id)[0]['descriptor']
    catalog = Catalog(catalog_factory, descriptor)
    return catalog.get_meta(key)
コード例 #15
0
def catalog_destroy(catalog_id):
    """
    Destroys a catalog.
    """
    descriptor = registry.lookup(catalog_id)[0]['descriptor']
    catalog = Catalog(catalog_factory, descriptor)
    catalog.destroy()
コード例 #16
0
ファイル: parser.py プロジェクト: mKliver/rosreestr2coord
    def __init__(self,
                 code="",
                 area_type=1,
                 epsilon=5,
                 media_path="",
                 with_log=True,
                 catalog="",
                 coord_out="EPSG:3857",
                 center_only=False,
                 with_proxy=False):
        self.with_log = with_log
        self.area_type = area_type
        self.media_path = media_path
        self.image_url = ""
        self.xy = []  # [[[area1], [hole1], [holeN]], [[area2]]]
        self.image_xy_corner = []  # cartesian coord from image, for draw plot
        self.width = 0
        self.height = 0
        self.image_path = ""
        self.extent = {}
        self.image_extent = {}
        self.center = {'x': None, 'y': None}
        self.center_only = center_only
        self.attrs = {}
        self.epsilon = epsilon
        self.code = code
        self.code_id = ""
        self.file_name = self.code[:].replace(":", "_")
        self.with_proxy = with_proxy

        self.coord_out = coord_out

        t = string.Template(SEARCH_URL)
        self.search_url = t.substitute({"area_type": area_type})
        t = string.Template(FEATURE_INFO_URL)
        self.feature_info_url = t.substitute({"area_type": area_type})

        if not self.media_path:
            # self.media_path = os.path.dirname(os.path.realpath(__file__))
            self.media_path = os.getcwd()
        if not os.path.isdir(self.media_path):
            os.makedirs(self.media_path)
        if catalog:
            self.catalog = Catalog(catalog)
            restore = self.catalog.find(self.code)
            if restore:
                self.restore(restore)
                self.log("%s - restored from %s" % (self.code, catalog))
                return
        if not code:
            return

        feature_info = self.download_feature_info()
        if feature_info:
            geometry = self.get_geometry()
            if catalog and geometry:
                self.catalog.update(self)
                self.catalog.close()
        else:
            self.log("Nothing found")
コード例 #17
0
ファイル: case.py プロジェクト: evaseemefly/gsconfig
def create_nc_coverage_merage_resource():
    '''
        # NOTE: 尝试将创建 nc coverage 使用 -> resource.py -> Coverage 的方式实现
        # TODO:[-] 20-03-23
    '''
    coverage_title = 'ceshi_coverage_01'
    # TODO:[*] 20-03-24 注意此处会引发严重bug,在指定 工作区 下若不存在指定的 store 会出现 错误
    store_name = 'nmefc_2016072112_opdr'
    coverage_store = 'nmefc_wind'
    layer_name = 'ceshi_coverage_01'
    work_space = 'my_test_2'
    cat: Catalog = Catalog("http://localhost:8082/geoserver/rest",
                           username="******",
                           password="******")
    ws = Workspace(cat, work_space)
    store = CoverageStore(cat, ws, 'nmefc_wind_dir_xy')

    # layer = CoverageLayer(cat, 'ceshi_name', 'ceshi_native_name', 'ceshi_tile', 'ceshi_native_coveragename')
    # coverage = Coverage(cat, ws, store, 'view_nmefc_wind')

    # TODO:[-] 20-03-24 使用 -> customer_layer -> CoverageLayer
    # coverage = CoverageLayer(cat, WORK_SPACE)
    # coverage.create_layer(coverage_title, store_name, [dict(name='x_wind_10m'), dict(name='y_wind_10m')])
    bands = [dict(name='x_wind_10m'), dict(name='y_wind_10m')]
    coverage_layer = CoverageLayer(cat, work_space, store_name)
    # TODO:[*] 20-03-24 此处若使用 layer_name:ceshi_coverage_01 而不使用 coverage_store:nmefc_wind 则会引发 msg 的bug
    coverage_layer.publish(layer_name, bands)
    pass
コード例 #18
0
def ExtractCatalogRecord(firebase: firebase, documentName: str, documentSemester: str, documentYear: str) -> Catalog:
    """
        Look if catalog record exists, if not - write it.

        :param firebase: a firebase connection
        :param documentName: a string representing the catalog document name
        :param documentSemester: a string representation of the catalog academic semester
        :param documentYear: a string representation of the catalog year

        :return Catalog object
    """

    catalog = Catalog()
    catalog.setDocumentName(documentName)
    catalog.setSemester(documentSemester)
    catalog.setYear(documentYear)

    existingKey = FindExistingCatalogId(catalog)

    if existingKey == "":
        newCatalogRecord = {
            'document_name': documentName,
            'semester': documentSemester,
            'year': documentYear
        }
        result = firebase.post('catalog', newCatalogRecord)
        catalog.setId(result.get("name"))
    else:
        catalog.setId(existingKey)

    return catalog
コード例 #19
0
 def __init__(self):
     self._objectNumber = 0
     self.objects = list()
     self.catalog = Catalog(self)
     self.outline = Outline(self)
     self.pageTree = PageTree(self)
     self.catalog.outlinesNumber = self.outline.objectNumber
     self.catalog.pageTreeNumber = self.pageTree.objectNumber
コード例 #20
0
ファイル: AF_EditTool.py プロジェクト: deju/afw_old
def fun_article_update_src(user,
                           article_id=0,
                           article_type='blog',
                           src_type='code',
                           alias='1',
                           title='',
                           body='',
                           source='',
                           code_type='python',
                           math_type='inline',
                           group_id='-1'):
    '''
        update the lib of the article, article_type is about|blog|comment
        article_id must be have
        need alias too, then we find the lib _id, create the object, and set of it
    '''
    if article_type not in Article_Type:
        return [1, '不支持当前文章类型!']
    if src_type not in Agree_Src:
        return [1, '暂不支持当前资源的类型!']

    if title is None:
        return [1, '请您填写标题/名称!']

    if src_type != 'image':
        if body is None:
            if src_type == 'r':
                if source is None:
                    return [1, '出处不能为空']
                if re.search(r'^(http|https|ftp):\/\/.+$', source) is None:
                    return [1, '请填写链接地址或者引用真实内容!']
                body = ''
            else:
                return [1, '内容不能为空!']

        if src_type == 'math':
            if math_type not in ['display', 'inline']:
                math_type = 'display'
                body = math_encode(xhtml_unescape(body))

        if src_type == 'code':
            if code_type not in Agree_Code:
                return [1, '目前不支持此类型的程序代码!']

    if article_type == "about":
        AF_Object = About(_id=user.about._id)
    elif article_type == "book-about":
        try:
            book = Catalog(_id=group_id)
            AF_Object = book.about
            limit = book.authority_verify(user)
            if test_auth(limit, A_WRITE) is False:
                return [1, '您无权修改!']
            pass
        except Exception, err:
            logging.error(traceback.format_exc())
            logging.error('Catalog not exist, id %s' % group_id)
            return [1, '未找到该知识谱!']
コード例 #21
0
 def __init__(self, object_name, catalog=None):
     if catalog is None:
         catalog = Catalog(os.path.join("data", "catalog.yml"))
     self.object = object_name
     self.layers = []
     self.default_colors = ['red', 'green', 'blue']
     self.shape = None
     self.catalog = catalog
     self.image = None
コード例 #22
0
def current_csv(ctx, remove_temp_dir):
    config = ctx.obj['config']

    with clone_repo(config, remove_temp_dir) as repo_dir:
        path = os.path.join(repo_dir, config['component'])
        channel = config['channel']

        catalog = Catalog(path, channel)
        click.echo(catalog.current_csv)
コード例 #23
0
ファイル: AF_BookTool.py プロジェクト: deju/afw_old
def fun_new_book(user=None, name='', summary=''):
    if user is None:
        return [1, '请您先登陆!']
    book = Catalog()
    book.owner = user
    book.name = name
    book.about.body = summary
    book_add_manager(book, user)

    return [0, str(book._id)]
コード例 #24
0
def insert_into_cat(cat, position, data):
    if len(position) == 0:
        cat.categories.append(data)
        return
    for i, subcat in enumerate(cat.categories):
        if subcat.item == position[0]:
            insert_into_cat(subcat, position[1:], data)
            return
    cat.categories.append(Catalog(position[0], []))
    insert_into_cat(cat.categories[-1], position[1:], data)
コード例 #25
0
ファイル: AF_BookTool.py プロジェクト: deju/afw_old
def fun_recommended_to_book(user=None, book_id='', node_id='', article_url=''):
    if user is None or book_id == '' or node_id == '':
        return [1, '参数错误!']
    if article_url == "":
        return [1, '请填写链接!']
    try:
        book = Catalog(_id=book_id)
    except Exception, err:
        logging.error(traceback.format_exc())
        logging.error('Catalog not exist, id %s' % book_id)
        return [1, '未找到知识谱!']
コード例 #26
0
ファイル: testCatalog.py プロジェクト: davidthomas5412/IM
    def testIO(self):
        cat1 = Catalog()
        cat1.addSource(0, 0, 20, 'sed.txt')
        fname = 'catalog.txt'
        cat1.toFile(fname)

        cat2 = Catalog.fromFile(fname)

        os.remove(fname)

        self.assertEquals(cat1.table['ra'], cat2.table['ra'])
コード例 #27
0
ファイル: case.py プロジェクト: evaseemefly/gsconfig
def case_bind_style_coverage(server_url: str, layer_name: str, style_name: str,
                             coverage_title: str, work_space: str):
    '''
        将 已经存在的 style 与 已经发布的 coverage 进行绑定
    '''

    cat = Catalog(server_url, username='******', password='******')
    # 使用 20-03-31 的新的方式实现
    # bind_layer_style(cat, layer_name, style_name, coverage_title, work_space)
    # TODO:[-] 20-03-31 此处已重新修改至 layer_style 中
    layer_style = LayerStyle(cat, work_space, layer_name)
    is_ok = layer_style.bind_layer_style(style_name, coverage_title)
    pass
コード例 #28
0
ファイル: case.py プロジェクト: evaseemefly/gsconfig
def create_nc_layer():
    '''
        测试创建 nc layer
    '''
    ws_name: str = 'my_test_2'
    cat: Catalog = Catalog("http://localhost:8082/geoserver/rest",
                           username="******",
                           password="******")
    layer = CoverageLayer(cat, 'ceshi_name', 'ceshi_native_name', 'ceshi_tile',
                          'ceshi_native_coveragename')
    # layer.message()

    pass
コード例 #29
0
    def __init__(self, config_file):
        """
        Trains and saves a model using Keras and TensorFlow

        :param config_file: json config file with settings including hyperparameters
        """

        with open(config_file) as json_file:
            self.config = json.load(json_file)
        self.catalog = Catalog()
        self.catalog.add_file_to_catalog(self.config['lyrics_file_path'])
        self.catalog.tokenize_catalog()
        self.is_interactive = self.config['is_interactive']
コード例 #30
0
ファイル: forms.py プロジェクト: linkaform/linkaform_api
 def __init__(self, **kwargs):
     self.all_forms = self.get_all_items('form')
     self.all_catalogs = self.get_all_items('catalog')
     self.form_id = self.get_item_id_from_file(kwargs['file_name'], 'form')
     self.catalog_id = self.get_item_id_from_file(kwargs['file_name'],
                                                  'catalog')
     self.geolocation = kwargs["geolocation"]
     self.start_timestamp = kwargs["start_timestamp"]
     self.end_timestamp = kwargs["start_timestamp"]
     #self.created_at = kwargs["created_at"]
     #self.answers = kwargs["answers"]
     #self.is_catalog =  kwargs["is_catalog"]
     self.catalog = Catalog()