Exemplo n.º 1
0
    def merge(self):
        print "Merging files"
        merge_file = 'M{}'.format(str(uuid.uuid4()).split('-')[-1])
        merge_catalog = Catalog(merge_file)
        merged_tokens = {}


        reader1 = InvertedIndexReader(self.catalog1)
        reader2 = InvertedIndexReader(self.catalog2)
        catalog1_dict = self.catalog1.get()
        catalog2_dict = self.catalog2.get()

        for term_id, offsets in catalog1_dict.iteritems():
            if term_id in catalog2_dict:
                positions_catalog1 = reader1.readAsDict(term_id)
                positions_catalog2 = reader2.readAsDict(term_id)
                positions_catalog1.update(positions_catalog2)
                merged_tokens[term_id] = positions_catalog1
                self.catalog2.delete(term_id)

            else:
                merged_tokens[term_id] = reader1.readAsDict(term_id)

        for term_id, offsets in catalog2_dict.iteritems():
            merged_tokens[term_id] = reader2.readAsDict(term_id)


        merge_writer = InvertedIndexWriter(merged_tokens, merge_catalog, merge_file)
        merge_writer.write(encode=False)
        print "Merging done!"
        return merge_catalog
Exemplo n.º 2
0
    def show_videos_init(self):
        
        ok = True
        cpt = 0

        file = xbmc.makeLegalFilename(os.path.join(self.CACHEDIR,self.FILENAME))
        f = open(file,'w')
        
        pDialog = xbmcgui.DialogProgress()
        ret = pDialog.create( 'XBMC', __language__ ( 30200 ) )        
        pDialog.update(0, __language__ ( 30202 ) )
        
        catalog = Catalog()
        self.NB_VIDEO = catalog.videos.__len__();
                 
        for video in catalog.videos:                 
            f.write('\n'.join(['%s;%s;%s;%s' % (video[Catalog.TITLE_TAG].encode('utf-8'),video[Catalog.DATE_TAG].encode('utf-8'), video[Catalog.URL_TAG].encode('utf-8'), video[Catalog.IMAGE_TAG].encode('utf-8'))]))
          
            cpt=cpt+1

            paramsAddons = {}
            paramsAddons[self.PARAM_PLAY_VIDEO]  = "true"
            paramsAddons[self.PARAM_VIDEO_ID]    = video[Catalog.URL_TAG]
            url = _create_param_url( paramsAddons )
                            
            infoLabels={ "Title": video[Catalog.DATE_TAG] + " - " + video[Catalog.TITLE_TAG],
                         "Date": video[Catalog.DATE_TAG]}            
            
            paramsAddonsContextMenu = {}
            paramsAddonsContextMenu[self.PARAM_DOWNLOAD_VIDEO]  = "true"
            paramsAddonsContextMenu[self.PARAM_VIDEO_ID]    = video[Catalog.URL_TAG]
            paramsAddonsContextMenu[self.PARAM_VIDEO_NAME]    = video[Catalog.TITLE_TAG]
            
            urlContextMenu = _create_param_url( paramsAddonsContextMenu )
            
            cm = _addContextMenuItems(name=video[Catalog.TITLE_TAG], url=urlContextMenu, msg= __language__(30102))
            
            _addLink( name=video[Catalog.TITLE_TAG], url=url, iconimage=video[Catalog.IMAGE_TAG], itemInfoLabels=infoLabels, c_items=cm )

            pDialog.update(int(99*float(cpt)/(self.NB_VIDEO)), __language__ ( 30202 ) )            
       
        pDialog.close()
        
        f.close()
                
        xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_NONE)
        xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category="referer" )
        xbmcplugin.setContent(int(sys.argv[1]), 'movies')
        _end_of_directory( True )

        return ok
Exemplo n.º 3
0
def section_list(SITE):
    print('FUNCTION -> system-> calalog -> section -> list')

    SITE.addHeadFile('/templates/system/css/style.css')
    section_id = SITE.p[2]

    CATALOG = Catalog(SITE)
    SECTION = Section(SITE)
    section = SECTION.getSection(section_id)
    catalog = CATALOG.getItem(section['catalog_id'])

    # Breadcrumbs
    data = {}
    data['catalog_id'] = catalog['id']
    data['parent_id'] = section['parent_id']
    breadcrubmps_list = SECTION.breadcrumbsPath(data)[::-1]

    breadcrumbs = ''

    if (len(breadcrubmps_list) > 0):
        for i in breadcrubmps_list:
            breadcrumbs += '<svg><use xlink:href="/templates/system/svg/sprite.svg#arrow_right_1"></use></svg>'
            breadcrumbs += '<a href="/system/catalog/section/' + str(
                i['id']) + '">' + i['name'] + '</a>'

    rows = SECTION.getItems(section_id)

    row_out = ''
    if (rows):
        i = 1
        for row in rows:
            status_tr_class = ''
            if row['status'] == 0:
                status_tr_class = 'class="admin_table_tr_unpub"'

            row_out += f'''<tr { status_tr_class }>
                <td>{ i }</td>
                <td>
                    <div class="flex_row contextmenu_wrap">
                        <svg class="contextmenu_ico" title="Действия" data-id="{ row['id'] }">
                            <use xlink:href="/templates/system/svg/sprite.svg#menu_3"></use>
                        </svg>
                    </div>
                </td>
                <td><a href="/system/catalog/item/edit/{ row['id'] }">{ row['name'] }</a></td>
            </tr>'''
            i += 1

    SITE.content += f'''<div class="bg_gray">
Exemplo n.º 4
0
def make_connection():
    catalog = Catalog(args.lang)
    f = os.path.join(ui.user_folder, 'database')
    if catalog.error:
        ui.on_error_data(catalog.error)
    else:
        try:
            with codecs.open(f, 'w', 'utf-8') as datalist:
                datalist.write('\n'.join([
                    '%s;%s;%s;%s' %
                    (video[Catalog.TITLE_TAG], video[Catalog.DATE_TAG],
                     video[Catalog.URL_TAG], video[Catalog.IMAGE_TAG])
                    for video in catalog.videos
                ]))
        except IOError as e:
            ui.on_error_data(e)
Exemplo n.º 5
0
    def __init__(self, env, floor):
        """
        Inits Inventory with the simulation environment and a reference to warehouse Floor layout

        During initialization, Inventory creates an instance of each Item in Catalog and distributes
        them across random Shelf objects within the warehouse

        Args:
            env: SimPy simulation environment
            floor: Floor object so we can communicate with this subset
        """
        self.clock = env
        self.floor = floor
        self.stock = []
        self.catalog = Catalog()

        self.populateStock()
        self.stockShelves()
Exemplo n.º 6
0
    def __init__(self, id, title='', vocab_id=None, container=None):
        # ZCatalog no longer cares about vocabularies
        # so the vocab_id argument is ignored (Casey)

        if container is not None:
            self = self.__of__(container)
        self.id = id
        self.title = title

        # vocabulary and vocab_id are left for backwards
        # compatibility only, they are not used anymore
        self.vocabulary = None
        self.vocab_id = ''

        self.threshold = 10000
        self._v_total = 0

        self._catalog = Catalog()
Exemplo n.º 7
0
def testmod():
    import doctest
    global testEntry, testCatalog, testToHtml, testArchiveToHtml

    urn = 'urn:x-internet-archive:bookserver:catalog'
    testCatalog = Catalog(title='Internet Archive OPDS', urn=urn)
    testLink = Link(url='http://archive.org/download/itemid.pdf',
                    type='application/pdf',
                    rel='http://opds-spec.org/acquisition/buying')
    catalogLink = Link(url='/providers/IA', type=Link.opds)
    testEntry = Entry(
        {
            'urn': 'x-internet-archive:item:itemid',
            'title': u'test item',
            'updated': '2009-01-01T00:00:00Z',
            'date': '1977-06-17T00:00:55Z',
            'summary': '<p>Fantastic book.</p>',
        },
        links=[testLink])

    start = 0
    numFound = 2
    numRows = 1
    urlBase = '/alpha/a/'
    testNavigation = Navigation.initWithBaseUrl(start, numRows, numFound,
                                                urlBase)
    testCatalog.addNavigation(testNavigation)

    osDescription = 'http://bookserver.archive.org/catalog/opensearch.xml'
    testSearch = OpenSearch(osDescription)
    testCatalog.addOpenSearch(testSearch)

    testCatalog.addEntry(testEntry)
    testToHtml = CatalogToHtml(testCatalog)

    testArchiveToHtml = ArchiveCatalogToHtml(testCatalog)

    doctest.testmod()
Exemplo n.º 8
0
from Catalog import Catalog
from User import Member

catalog = Catalog()

b = catalog.addBook('Shoe Dog', 'Phil Knight', '2015', 312)
catalog.addBookItem(b, '123hg', 'H1B2')
catalog.addBookItem(b, '124hg', 'H1B4')
catalog.addBookItem(b, '125hg', 'H1B5')

b = catalog.addBook('Moonwalking with Einstien', 'J Foer', '2017', 318)
catalog.addBookItem(b, '463hg', 'K1B2')

b = catalog.addBook('Pax', 'Sara Pennypacker', '2017', 288)
catalog.addBookItem(b, '554jk', 'M24A')
catalog.addBookItem(b, '556jk', 'M25A')
catalog.addBookItem(b, '557jk', 'M26A')

catalog.displayAllBooks()

catalog.removeBook('Pax')

catalog.displayAllBooks()

catalog.removeBookItem('Shoe Dog', '124hg')
catalog.displayAllBooks()

b = catalog.searchByName('Shoe Dog')
print(b)

b = catalog.searchByAuthor('J Foer')
Exemplo n.º 9
0
 def addBook(self, name, author, publish_date, pages):
     catalog = Catalog()
     b = catalog.addBook(name, author, publish_date, pages)
     return b
Exemplo n.º 10
0
import datetime
import json
from HashTable import HashTable
from Catalog import Catalog, Course

###############################################################

### Greg's Catalog with Dictionary ###
data = {}

with open('catalog.txt', 'r') as f:
    data = json.loads(f.read())

start_time = datetime.datetime.now()

catalog = Catalog({})
for subject, courses in data.items():
    course_data = {}
    for course, info in courses.items():
        course_data[course] = Course(*info.values())
    catalog.subjects[subject] = course_data

print(catalog.get_subject('Special Education'))

end_time = datetime.datetime.now()
print(end_time - start_time)
###############################################################

del start_time
del end_time
del catalog
Exemplo n.º 11
0
 def __writeInvertedIndex(self, inverted_list):
     print "Writing inverted index to disk and creating the catalog"
     catalog_name = str(uuid.uuid4()).split('-')[-1]
     catalog = Catalog(catalog_name)
     writer = InvertedIndexWriter(inverted_list, catalog, catalog_name)
     self.catalogs[catalog_name] = writer.write()
Exemplo n.º 12
0
 def issueBook(book,librarian_id,librarian_name,issueDay):
     catalog = Catalog()
     catalog.setLibrarianForBookItem(book, librarian_id, librarian_name, issueDay)
Exemplo n.º 13
0
 def returnBook(book, librarian_id):
     catalog = Catalog()
     catalog.retunBookUpdateCatalog(book, librarian_id)
Exemplo n.º 14
0
#!/usr/bin/python

# Catalog of Weekly Advertising.
from Catalog import Catalog

# Services to work with documents.
import DocumentServices

grouping = "testgrouping"
retailer = "testretailer"
catalog = Catalog("testLocation", "testWeb")
catalog.mValidFrom = "2017_01_01"
catalogs = {"testStore-testLocation-externalName-2017_01_01": catalog}

outputDir = "./testoutput/"
print("  -> Write Catalogs to XLSX")
DocumentServices.writeCatalogsToSpreadsheet(grouping, retailer, catalogs,
                                            outputDir)
print("  -> Write Catalogs to CSV")
DocumentServices.writeCatalogsToCsv(grouping, retailer, catalogs, outputDir)

print("  -> Write Catalogs to PDF")
DocumentServices.writeCatalogsToPdf(grouping, retailer, catalogs, outputDir)

print("  -> Write Catalogs Images to Disk")
DocumentServices.writeCatalogsImagesToDisk(grouping, retailer, catalogs,
                                           outputDir)
Exemplo n.º 15
0
Arquivo: edit.py Projeto: dseolog/dan
def edit(SITE):
    print('PATH -> system/catalog/section/edit')
    SITE.addHeadFile('/plugins/ckeditor/ckeditor.js')
    SITE.addHeadFile('/lib/DAN/tooltip/tooltip.css')

    CATALOG = Catalog(SITE)
    SECTION = Section(SITE)
    FILTER = Filter(SITE)

    if SITE.p[2] == 'edit':
        SITE.addHeadFile('/lib/DRAG_N_DROP/DRAG_DROP.css')
        SITE.addHeadFile('/lib/DRAG_N_DROP/DRAG_DROP.js')
        SITE.addHeadFile('/templates/system/catalog/section/edit.js')
        SITE.addHeadFile('/templates/system/catalog/section/edit.css')
        section = SECTION.getSection(SITE.p[3])
        catalog_id = section['catalog_id']
        catalog = CATALOG.getItem(catalog_id)
        title = 'Редактировать раздел'
        action = 'update/' + SITE.p[3]
        filters = FILTER.getFiltersBySectionId(section['id'])
    else:
        catalog_id = SITE.p[3]
        catalog = CATALOG.getItem(catalog_id)
        title = 'Добавить  раздел'
        action = 'insert'
        # ordering = SECTION.getMaxOrdering() + 1
        ordering = 1
        section = {
            'id': 0,
            'parent_id': 0,
            'name': '',
            'text': '',
            'data': '',
            'status': 1,
            'ordering': ordering
        }
        filters = ''

    rows = SECTION.tree(catalog_id)
    sec_options = ''
    tabu_level = 1000  # Уровень, ниже которого опускаться нельзя для дочерних пунктов нашего раздела
    if (rows):
        for row in rows:

            if row['id'] == section['id']:
                # Если это текущий раздел, не отображать его и дочерние разделы
                tabu_level = row['level']
                continue

            if row['level'] <= tabu_level:
                # Вышли из дочерних разделов текущего раздела - всё сбрасываем
                tabu_level = 1000
                level = '&nbsp;-&nbsp;' * row['level']
                selected = 'selected' if row['id'] == section[
                    'parent_id'] else ''
                sec_options += f'''<option { selected } value="{ row['id'] }">{ level }{ row['name'] }</option>'''

    filters_out = ''

    if filters:
        for filter in filters:
            if filter['type'] == 'number':
                type_out = '<td class="section_filter_tab_type">число</td>'
                type_out += '<td class="section_filter_tab_value">'
                type_out += '<input draggable="false" class="input section_filter_input_number" type="text" name="filter_value_1[]" value="' + filter[
                    'value_1'] + '">'
                type_out += '<input draggable="false" class="input section_filter_input_number" type="text" name="filter_value_2[]" value="' + filter[
                    'value_2'] + '">'
                type_out += '</td>'

            if filter['type'] == 'string':
                type_out = '<td class="section_filter_tab_type">строка</td>'
                type_out += '<td class="section_filter_tab_value">'
                type_out += '<input draggable="false" class="input section_filter_input_string" type="text" name="filter_value_1[]" value="' + filter[
                    'value_1'] + '">'
                type_out += '<input class="input section_filter_input_string" type="hidden" name="filter_value_2[]" value="">'
                type_out += '</td>'

            filters_out += '<table class="section_filter_tab" draggable="true" data-id="' + str(
                filter['id']) + '" data-char_name_id="' + str(
                    filter['name_id']) + '">'
            filters_out += '<tr>'
            filters_out += '<td class="section_filter_tab_ico_dnd">'
            filters_out += '<div class="flex_row contextmenu_wrap">'
            filters_out += '<svg class="drag_drop_ico" title="Перетащить" data-id="' + str(
                filter['name_id']
            ) + '" data-target-id="section_filter_list" data-class="section_filter_tab" data-direction="y" data-f="SYSTEM.catalog.section.filter_ordering">'
            filters_out += '<use xlink:href="/templates/system/svg/sprite.svg#cursor24"></use></svg>'
            filters_out += '</div>'
            filters_out += '</td>'
            filters_out += '<td class="section_filter_tab_name">'
            filters_out += filter['name'] + ' (' + filter['name'] + ')'
            filters_out += '<input type="hidden" name="filter_id[]" value="' + str(
                filter['id']) + '">'
            filters_out += '<input type="hidden" name="filter_char_id[]" value="' + str(
                filter['name_id']) + '">'
            filters_out += '</td>'
            filters_out += type_out
            filters_out += '<td class="section_filter_tab_delete">'
            filters_out += '<svg class="section_filter_delete" data-id="' + str(
                filter['id']
            ) + '"><use xlink:href="/templates/system/svg/sprite.svg#delete"></use></svg>'
            filters_out += '</td>'
            filters_out += '</tr>'
            filters_out += '</table>'

    SITE.content += '''<div class="bg_gray">
        <h1>''' + title + '''</h1>
        <div class="breadcrumbs">
            <a href="/system/"><svg class="home"><use xlink:href="/templates/system/svg/sprite.svg#home"></use></svg></a> 
            <svg><use xlink:href="/templates/system/svg/sprite.svg#arrow_right_1"></use></svg>
            <a href="/system/catalog/cat">Каталог</a>
            <svg><use xlink:href="/templates/system/svg/sprite.svg#arrow_right_1"></use></svg>
			<a href="/system/catalog/cat/''' + str(
        catalog_id) + '''">''' + catalog['name'] + '''</a>
            <svg><use xlink:href="/templates/system/svg/sprite.svg#arrow_right_1"></use></svg>
            <span>''' + title + '''</span>
        </div>
		<form method="post" action="/system/catalog/section/''' + action + '''">
			<div class="tc_container">
				<div class="flex_row p_5_20">
					<div class="tc_item_l">Наименование</div>
					<div class="tc_item_r flex_grow">
						<input class="input input_long" name="name" placeholder="Раздел 1" required value="''' + section[
            'name'] + '''">
					</div>
				</div>
				<div class="flex_row p_5_20">
					<div class="tc_item_l">Родительский раздел</div>
					<div class="tc_item_r flex_grow">
						<select class="input" name="parent_id">
                            <option value="0">Нет</option>
                            ''' + sec_options + '''
                        </select>
					</div>
				</div>
				<div class="flex_row p_5_20">
                    <div class="tc_item_l">Текст</div>
                    <div class="tc_item_r flex_grow"> 
					    <textarea id="editor1" name="text">''' + section[
                'text'] + '''</textarea>
                    </div>
				</div>
                <div class="flex_row p_5_20">
      				<div class="tc_item_l">Данные</div>
					<div class="tc_item_r flex_grow">          
					    <textarea class="input" name="data" style="width:100%;height:100px;">''' + section[
                    'data'] + '''</textarea>
                    </div>
				</div>
				<div class="flex_row p_5_20">
					<div class="tc_item_l">Статус</div>
					<div class="tc_item_r flex_grow">
						<input class="input" name="status" type="number" value="''' + str(
                        section['status']) + '''">
					</div>
				</div>
				<div class="flex_row p_5_20">
					<div class="tc_item_l">Порядок следования</div>
					<div class="tc_item_r flex_grow">
						<input class="input" name="ordering" type="number" value="''' + str(
                            section['ordering']) + '''">
					</div>
				</div>
                <div class="flex_row accordion_container">
                    <div class="dan_accordion_container">
                        <input class="dan_accordion_checkbox" type="checkbox">
                        <div class="dan_accordion_head">
                            <svg class="icon"><use xlink:href="/templates/system/svg/sprite.svg#filter"></use></svg>
                            <div class="dan_accordion_head_indicator"></div>
                            <div class="dan_accordion_head_title">ФИЛЬТРЫ ПО ХАРАКТЕРИСТИКАМ</div>
                        </div>
                        <div class="dan_accordion_content">
                            <div class="section_filter_button_wrap">
                                <div id="section_filter_add" class="section_filter_add_button" data-catalog_id="''' + str(
                                catalog_id) + '''">Добавить фильтр</div>
                            </div>
                            <div>
                                <table class="section_filter_title_tab">
                                    <tr>
                                        <td class="section_filter_tab_ico_dnd">&nbsp;</td>
                                        <td class="section_filter_tab_name">
                                            <div class="section_filter_column_title"><b>Фильтр по хар-ке</b></div>
                                            <div class="tooltip">
                                                <em>Фильтры</em>
                                                <p>Позволяют фильтровать товары по характеристикам, примеры:</p>
                                                <b>Цвет: </b>
                                                <select class="input" size="1" name="D1">
                                                    <option value="Характеристика 1">белый</option>
                                                    <option value="Характеристика 2">синий</option>
                                                    <option value="Характеристика 3">красный</option>
                                                </select>
                                                <br>
                                                <b>Длина: </b><input class="input" type="text" name="T1" size="5" value="80">см.&nbsp;
                                                до <input class="input" type="text" name="T2" size="5" value="120">см.
                                                <br>
                                            </div>
                                        </td>
                                        <td class="section_filter_tab_type"><b>Тип</b></td>
                                        <td class="section_filter_tab_value">
                                            <div class="section_filter_column_title"><b>Значения полей фильтра</b></div>
                                            <div class="tooltip">
                                                <em>Значение полей фильтра</em>
                                                <p>Для типа данных <i>строка</i> вводите значения фильтра  через точку с запятой, например: <b>белый;синий;красный</b></p>
                                                <p>&nbsp;</p>
                                                <p>Для типа данных <i>число</i> введите значения фильтра  <b>от</b> <i>число</i> <b>до</b> <i>число</i></p>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <div id="section_filter_list" data-id="">''' + filters_out + '''.</div>
                        </div>
                    </div>
                </div>
				<div class="flex_row p_40_20">
					<div class="tc_item_l"><input class="button_green" type="submit" name="submit" value="Сохранить"></div>
					<div class="tc_item_r flex_grow"><input class="button_white" type="submit" name="cancel" value="Отменить"></div>
				</div>
			</div>
            <input class="input" name="catalog_id" type="hidden" value="''' + str(
                                    catalog_id) + '''">
Exemplo n.º 16
0
from Book import Book
from Catalog import Catalog
from User import User
from User import Member, Librarian

c = Catalog()
b1 = c.addBook('Politics of Opportunism','R P N Singh', '2019',100)
c.addBookItem(b1,'isbn1','R1')
c.addBookItem(b1,'isbn1-2','R1-2')
b2 = c.addBook('Malayalam poetry','Akkitham Achuthan Namboodri', '2019',130)
c.addBookItem(b2,'isbn2','R2')
b3 = c.addBook('Celestial Bodies','Jokha Alharthi', '2019',140)
c.addBookItem(b3,'isbn3','R3')

m = Member('member1','bangalore',24,'123412341234',25,c)
bi1 = m.issueBook('Politics of Opportunism')
bi2 = m.issueBook('Politics of Opportunism')
m.returnBook(bi1)
bi3 = m.issueBook('Politics of Opportunism')
bi4 = m.issueBook('Politics of Opportunism')