コード例 #1
0
ファイル: shell.py プロジェクト: sl4shme/freezer
def do_job_get(client, args):
    if not args.job_id:
        raise Exception("Parameter --job required")
    job_doc = client.jobs.get(args.job_id)
    if args.fname:
        args.save_doc_to_file(job_doc, args.fname)
    else:
        pprint(job_doc)
コード例 #2
0
def do_job_get(client, args):
    if not args.job_id:
        raise Exception("Parameter --job required")
    job_doc = client.jobs.get(args.job_id)
    if args.fname:
        args.save_doc_to_file(job_doc, args.fname)
    else:
        pprint(job_doc)
コード例 #3
0
ファイル: OMXPlayerEngine.py プロジェクト: kktuax/youtupi
 def prepareSubtitles(self, fname, video):
     try:
         id = 1
         with codecs.open(fname, "w", "utf-8") as f:
             if "title" in video.data:
                 f.write(self.subtitleBlock(id, video.data["title"]))
                 id += 1
             if "description" in video.data:
                 f.write(self.subtitleBlock(id, video.data["description"]))
                 id += 1
     except Exception as e:
         pprint(e)
コード例 #4
0
 def prepareSubtitles(self, fname, video):
     try:
         id = 1
         with codecs.open(fname, 'w', 'utf-8') as f:
             if 'title' in video.data:
                 f.write(self.subtitleBlock(id, video.data['title']))
                 id += 1
             if 'description' in video.data:
                 f.write(self.subtitleBlock(id, video.data['description']))
                 id += 1
     except Exception as e:
         pprint(e)
コード例 #5
0
ファイル: OMXPlayerEngine.py プロジェクト: orithena/youtupi
 def prepareSubtitles(self, fname, video):
     try:
         id = 1
         with codecs.open(fname, 'w', 'utf-8') as f:
             if 'title' in video.data:
                 f.write(self.subtitleBlock(id, video.data['title']))
                 id += 1
             if 'description' in video.data:
                 f.write(self.subtitleBlock(id, video.data['description']))
                 id += 1
     except Exception as e: 
         pprint(e)
コード例 #6
0
def do_session_get(client, args):
    """
    gets a specific session object and saves it to file. If file is not
    specified the session obj is printed.
    :return: None
    """
    if not args.session_id:
        raise Exception("Parameter --session required")
    session_doc = client.sessions.get(args.session_id)
    if args.fname:
        utils.save_doc_to_json_file(session_doc, args.fname)
    else:
        pprint(session_doc)
コード例 #7
0
ファイル: shell.py プロジェクト: sl4shme/freezer
def do_session_get(client, args):
    """
    gets a specific session object and saves it to file. If file is not
    specified the session obj is printed.
    :return: None
    """
    if not args.session_id:
        raise Exception("Parameter --session required")
    session_doc = client.sessions.get(args.session_id)
    if args.fname:
        utils.save_doc_to_json_file(session_doc, args.fname)
    else:
        pprint(session_doc)
コード例 #8
0
ファイル: base.py プロジェクト: jesse1983/pymay
    def __convert_types__(self, result):
        attrs = self.__class__.__dict__["_properties"]
        for prop in attrs:
            pprint.pprint({'__class__':str(attrs[prop])})
            if "EnumProperty" in str(attrs[prop]):
                result[prop] = str(getattr(self, prop))
            if "KeyProperty" in str(attrs[prop]):
                if type(getattr(self, prop)) is not list:
                    result[prop] = getattr(self, prop).id()
            if "DateTimeProperty" in str(attrs[prop]):
                result[prop] = getattr(self, prop).strftime(DATE_FORMAT)
            if "DateProperty" in str(attrs[prop]):
                result[prop] = getattr(self, prop).strftime(DATE_FORMAT)


        return result
コード例 #9
0
def get_action_dicts(
        csv_file
) -> Iterator[Dict[str, Union[str, Dict[str, Union[str, float]]]]]:
    """A generator which yields elasticsearch action dicts for groups of records
    with one DPA and zero or one BPLU
    """
    data_reader = csv.reader(csv_file)
    entry_datetime = None  # type: str

    for _, group in groupby(data_reader, itemgetter(UPRN)):
        rows = list(group)
        if len(rows) == 1 and int(rows[0][RECORD_IDENTIFIER]) == HEADER_ID:
            header = Header(*rows[0])
            # we use 'date_time_no_millis' format: yyyy-MM-dd’T'HH:mm:ssZZ
            # we assume UTC (+00) as the spec doesn't specify a timezone
            entry_datetime = '{}T{}+00'.format(header.entry_date,
                                               header.time_stamp)

            continue

        blpu_list = []  # type: List[BLPU]
        dpa_list = []  # type: List[DPA]
        # create namedtuples from each line
        for row in rows:
            rec_type = int(row[RECORD_IDENTIFIER])
            # create a record using the values in the row
            if rec_type == BLPU_ID:
                blpu_list += [BLPU(*row)]
            elif rec_type == DPA_ID:
                dpa_list += [DPA(*row)]

        # we must have one DPA and zero or one BPLU
        if len(dpa_list) == 1 and len(blpu_list) in [0, 1]:
            dpa = dpa_list[0]
            blpu = []
            if len(blpu_list) == 1:
                blpu = blpu_list[0]
            action_dicts = make_es_actions(dpa, blpu, entry_datetime)

            pprint(action_dicts, width=1)

            for action_dict in action_dicts:
                yield action_dict
コード例 #10
0
def get_action_dicts(csv_file) -> Iterator[Dict[str, Union[str, Dict[str, Union[str, float]]]]]:
    """A generator which yields elasticsearch action dicts for groups of records
    with one DPA and zero or one BPLU
    """
    data_reader = csv.reader(csv_file)
    entry_datetime = None  # type: str

    for _, group in groupby(data_reader, itemgetter(UPRN)):
        rows = list(group)
        if len(rows) == 1 and int(rows[0][RECORD_IDENTIFIER]) == HEADER_ID:
            header = Header(*rows[0])
            # we use 'date_time_no_millis' format: yyyy-MM-dd’T'HH:mm:ssZZ
            # we assume UTC (+00) as the spec doesn't specify a timezone
            entry_datetime = "{}T{}+00".format(header.entry_date, header.time_stamp)

            continue

        blpu_list = []  # type: List[BLPU]
        dpa_list = []  # type: List[DPA]
        # create namedtuples from each line
        for row in rows:
            rec_type = int(row[RECORD_IDENTIFIER])
            # create a record using the values in the row
            if rec_type == BLPU_ID:
                blpu_list += [BLPU(*row)]
            elif rec_type == DPA_ID:
                dpa_list += [DPA(*row)]

        # we must have one DPA and zero or one BPLU
        if len(dpa_list) == 1 and len(blpu_list) in [0, 1]:
            dpa = dpa_list[0]
            blpu = []
            if len(blpu_list) == 1:
                blpu = blpu_list[0]
            action_dicts = make_es_actions(dpa, blpu, entry_datetime)

            pprint(action_dicts, width=1)

            for action_dict in action_dicts:
                yield action_dict