Пример #1
0
 def unified_diff(self):
     """Return a unified diff"""
     a = [safe_utf8(i) for i in
          self._parseField(self.oldValue, filename=self.oldFilename)]
     b = [safe_utf8(i) for i in
          self._parseField(self.newValue, filename=self.newFilename)]
     return linesep.join(difflib.unified_diff(a, b, self.id1, self.id2))
Пример #2
0
    def _parse_arguments(self, args):
        config_path = os.path.join(
            CURRENT_PATH,
            'exemplar_data/exemplar_config.json')

        log_dir = tempfile.mkdtemp()
        log_path = os.path.join(log_dir, 'linkchecker.log')
        open(log_path, 'a').close()

        self.config_file_path = safe_utf8(config_path)
        self.log_file_path = safe_utf8(log_path)
Пример #3
0
 def unified_diff(self):
     """Return a unified diff"""
     a = [
         safe_utf8(i)
         for i in self._parseField(self.oldValue, filename=self.oldFilename)
     ]
     b = [
         safe_utf8(i)
         for i in self._parseField(self.newValue, filename=self.newFilename)
     ]
     return linesep.join(difflib.unified_diff(a, b, self.id1, self.id2))
Пример #4
0
 def unified_diff(self):
     """Return a unified diff"""
     a = self._parseField(self.oldValue, filename=self.oldFilename)
     b = self._parseField(self.newValue, filename=self.newFilename)
     if six.PY2:
         a = [safe_utf8(i) for i in a]
         b = [safe_utf8(i) for i in b]
     # in py3 unified_diff does not accept None for ids (id1 and id2)
     # But TextDiff() sets None as default. We overwrite this here so the
     # default of unified_diff ('') can be used .
     cleanargs = [a, b, self.id1, self.id2]
     cleanargs = [i for i in cleanargs if i]
     return linesep.join(difflib.unified_diff(*cleanargs))
Пример #5
0
 def unified_diff(self):
     """Return a unified diff"""
     a = self._parseField(self.oldValue, filename=self.oldFilename)
     b = self._parseField(self.newValue, filename=self.newFilename)
     if six.PY2:
         a = [safe_utf8(i) for i in a]
         b = [safe_utf8(i) for i in b]
     # in py3 unified_diff does not accept None for ids (id1 and id2)
     # But TextDiff() sets None as default. We overwrite this here so the
     # default of unified_diff ('') can be used .
     cleanargs = [a, b, self.id1, self.id2]
     cleanargs = [i for i in cleanargs if i]
     return linesep.join(difflib.unified_diff(*cleanargs))
Пример #6
0
    def _parse_arguments(self, args):
        parser = argparse.ArgumentParser(
            usage='bin/instance check_links settings [-l logpath] [-p processes]')
        parser.add_argument('-c', '--command', help=argparse.SUPPRESS)
        parser.add_argument('settings',
                            help='Path of the linkchecker settings file.')
        parser.add_argument('-l', '--logpath',
                            help='Path of the linkchecker log file.')
        parser.add_argument('-p', '--processes', type=int,
                            help='Max. number of processes spawned.')
        args = parser.parse_args()

        self.config_file_path = safe_utf8(args.settings)
        self.log_file_path = safe_utf8(args.logpath)
        self.max_processes = int(args.processes)
Пример #7
0
 def html_diff(self, context=True, wrapcolumn=40):
     """Return an HTML table showing differences"""
     # difflib is not Unicode-aware, so we need to force everything to
     # utf-8 manually
     a = [safe_unicode(i) for i in self._parseField(self.oldValue, filename=self.oldFilename)]
     b = [safe_unicode(i) for i in self._parseField(self.newValue, filename=self.newFilename)]
     vis_diff = difflib.HtmlDiff(wrapcolumn=wrapcolumn)
     diff = safe_utf8(vis_diff.make_table(a, b, safe_unicode(self.id1), safe_unicode(self.id2), context=context))
     return diff
Пример #8
0
    def sync_related_task(self, task, transition, text, **kwargs):
        payload = {'transition': transition, 'text': safe_utf8(text or '')}
        self.extend_payload(payload, task, **kwargs)

        response = self._dispatch_request(task.admin_unit_id,
                                          self.TARGET_SYNC_VIEW_NAME,
                                          task.physical_path,
                                          data=payload)

        response_data = response.read().strip()
        if response_data != 'OK':
            self.raise_sync_exception(task, transition, text, **kwargs)
Пример #9
0
    def __call__(self):
        searchable = []
        # append some other attributes to the searchableText index
        # reference_number
        refNumb = getAdapter(self.context, IReferenceNumber)
        searchable.append(refNumb.get_number())

        # sequence_number
        seqNumb = getUtility(ISequenceNumber)
        searchable.append(str(seqNumb.get_number(self.context)))

        # keywords
        keywords = IDocumentMetadata(self.context).keywords
        if keywords:
            searchable.extend(safe_utf8(keyword) for keyword in keywords)

        return ' '.join(searchable)
Пример #10
0
    def sync_deadline(self, new_deadline, text, transition):
        sct = ISuccessorTaskController(self.context)
        for successor in sct.get_successors():

            response = dispatch_request(
                successor.admin_unit_id,
                '@@remote_deadline_modifier',
                successor.physical_path,
                data={
                    'new_deadline': new_deadline.toordinal(),
                    'text': safe_utf8(text),
                    'transition': transition})

            if response.read().strip() != 'OK':
                raise Exception(
                    'Updating deadline on remote client %s. failed (%s)' % (
                        successor.admin_unit_id, response.read()))
Пример #11
0
def linked_subjects(item, subjects):
    if not subjects:
        return ''

    subjects = sorted(subjects)
    links = []

    for subject in subjects:

        subject = escape_html(safe_utf8(subject))
        quoted_subject = quote_plus(subject)

        url = u'{}/@@search?Subject={}'.format(
            api.portal.get().absolute_url(), quoted_subject)

        links.append(u'<a href="{}" class="subjectLinks">{}</a>'.format(
            url, safe_unicode(subject)))

    return u', '.join(links)
Пример #12
0
 def html_diff(self, context=True, wrapcolumn=40):
     """Return an HTML table showing differences"""
     # difflib is not Unicode-aware, so we need to force everything to
     # utf-8 manually
     a = [
         safe_unicode(i)
         for i in self._parseField(self.oldValue, filename=self.oldFilename)
     ]
     b = [
         safe_unicode(i)
         for i in self._parseField(self.newValue, filename=self.newFilename)
     ]
     vis_diff = difflib.HtmlDiff(wrapcolumn=wrapcolumn)
     diff = safe_utf8(
         vis_diff.make_table(a,
                             b,
                             safe_unicode(self.id1),
                             safe_unicode(self.id2),
                             context=context))
     return diff
Пример #13
0
    def __call__(self):
        searchable = []
        # append some other attributes to the searchableText index
        # reference_number
        refNumb = getAdapter(self.context, IReferenceNumber)
        searchable.append(refNumb.get_number())

        # sequence_number
        seqNumb = getUtility(ISequenceNumber)
        searchable.append(str(seqNumb.get_number(self.context)))

        fulltext_indexer = getAdapter(self.context, IDocumentIndexer)
        fulltext = fulltext_indexer.extract_text()
        if fulltext:
            searchable.append(fulltext)

        # keywords
        keywords = IDocumentMetadata(self.context).keywords
        if keywords:
            searchable.extend(safe_utf8(keyword) for keyword in keywords)

        return ' '.join(searchable)
Пример #14
0
 def __init__(self, site_name, site_info):
     self.site_name = safe_utf8(site_name)
     self.email = [safe_utf8(email) for email in site_info.get('email', [])]
     self.base_uri = safe_utf8(site_info.get('base_uri', ''))
     self.timeout_config = int(site_info.get('timeout_config', 1))
     self.upload_location = safe_utf8(site_info.get('upload_location', ''))
Пример #15
0
 def _make_token(self, value):
     return b2a_qp(safe_utf8(value))
Пример #16
0
 def _make_token(self, value):
     return b2a_qp(safe_utf8(value))