Small utility for changing comment in a zip file
        without changing the file modification datetime.
354654
def toto(arch_name, comment='', clear=False, read_comment=False, list_members=False, time_show=False):
    
    if comment and clear:
        clingon.RunnerError("You cannot specify --comment and --clear together")
    z = None
    # if archive does not exist, create it with up to 3 files from current directory
    if not os.path.isfile(arch_name):
        print "Creating archive", arch_name
        z = zipfile.ZipFile(arch_name, 'w')
        for f in [x for x in glob.iglob('*.*') if not x.endswith('.zip')][:3]:
            print "  Add file %s to %s" % (f, arch_name)
            z.write(f)
    if comment:
        mtime = os.path.getmtime(arch_name)
        if not z:
            z = zipfile.ZipFile(arch_name, 'a')
        z.comment = comment
    if z:
        z.close()
        if comment:
            os.utime(arch_name, (time.time(), mtime))
    if read_comment:
        z = zipfile.ZipFile(arch_name, 'r')
        print "Comment:", z.comment, len(z.comment)
    if list_members:
        z = zipfile.ZipFile(arch_name, 'r')
        print "Members:", z.namelist()
    if time_show:
        print "Access time:", time.ctime(os.path.getatime(arch_name))
        print "Modif time:", time.ctime(os.path.getmtime(arch_name))
890718
def files_comments_delete(self, *, file: str, id: str, **kwargs) -> SlackResponse:
        
        kwargs.update({"file": file, "id": id})
        return self.api_call("files.comments.delete", json=kwargs)
262991
def _set_comment(self, section, comment, key=None):
        

        if '\n' in comment:
            comment = '\n# '.join(comment.split('\n'))
        comment = '# ' + comment

        if key:
            self._comments[(section, key)] = comment
        else:
            self._comments[section] = comment
290114
def toggle(self, index, n_cols=70):
        
        data = self.get(index)

        if data['type'] == 'Submission':
            # Can't hide the submission!
            pass

        elif data['type'] == 'Comment':
            cache = [data]
            count = 1
            for d in self.iterate(index + 1, 1, n_cols):
                if d['level'] <= data['level']:
                    break

                count += d.get('count', 1)
                cache.append(d)

            comment = {
                'type': 'HiddenComment',
                'cache': cache,
                'count': count,
                'level': data['level'],
                'body': 'Hidden',
                'hidden': True}

            self._comment_data[index:index + len(cache)] = [comment]

        elif data['type'] == 'HiddenComment':
            self._comment_data[index:index + 1] = data['cache']

        elif data['type'] == 'MoreComments':
            with self._loader('Loading comments'):
                # Undefined behavior if using a nested loader here
                assert self._loader.depth == 1
                comments = data['object'].comments(update=True)
            if not self._loader.exception:
                comments = self.flatten_comments(comments, data['level'])
                comment_data = [self.strip_praw_comment(c) for c in comments]
                self._comment_data[index:index + 1] = comment_data

        else:
            raise ValueError('%s type not recognized' % data['type'])
298725
def modify(file, content = nil)
      Pathname.new(file).tap do |file|
        file.open('w') { |f| f.write(content) } if content
        future = Time.now + 60
        file.utime future, future
      end
    end
115085
def add_comment(self, body, allow_create=False, allow_hashes=False,
                    summary=None):
        ""

        if allow_hashes:
            raise ValueError('allow_hashes not implemented for %s yet' % (
                self.__class__.__name__))
        if self.thread_id is None:
            self.thread_id = self.lookup_thread_id()
        if not os.path.exists(self.thread_id):
            if not allow_create:
                raise KeyError(self.topic)
            with open(self.thread_id, 'a', newline='') as fdesc:
                csv.writer(fdesc).writerow(self.header)

        with open(self.thread_id, 'a', newline='') as fdesc:
            writer = csv.writer(fdesc)
            writer.writerow([self.user, datetime.datetime.utcnow(), summary,
                             body, ''])
280665
def cli(ctx, id_number, new_value, metadata=""):
    
    return ctx.gi.cannedcomments.update_comment(id_number, new_value, metadata=metadata)
761941
def _strip_comments(line):
        
        if line == '':
            return line
        r = re.search('(?P<line>[^#]*)(#(?P<comment>.*))?', line)
        if r:
            line = r.group('line')
            if not line.endswith('\n'):
                line += '\n'
            return line
        return '\n'
846383
def modification_time(self):
    """"""
    timestamps = self._gzip_file.modification_times
    if not timestamps:
      return None
    return dfdatetime_posix_time.PosixTime(timestamp=timestamps[0])
1022047
def adapt_comment!(parsed_comment)
      # Saving off the original data
      parsed_comment['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_comment))

      parsed_comment['text'] = parsed_comment.delete(:text)
      parsed_comment['line'] = parsed_comment.delete(:location)[:line]
    end
117862
def modification_time(self):
    """"""
    timestamp = self._fsntfs_file_entry.get_modification_time_as_integer()
    return dfdatetime_filetime.Filetime(timestamp=timestamp)
963481
def _comment_system_for_file(contents):
    """"""
    if contents[0] == "#":
        return FileCommentSystem(begin="#", middle="", end="", single="#")
    elif contents[:2] == "/*":
        return FileCommentSystem(begin="/*", middle="*", end="*/", single="//")
    elif contents[:2] == "//":
        return FileCommentSystem(begin="//", middle="//", end="", single="//")
    elif contents[:3] == "rem":
        return FileCommentSystem(begin="rem",
                                 middle="rem",
                                 end="",
                                 single="rem")
    else:
        raise RuntimeError("Couldn't detect comment "
                           "system from {0}".format(contents[:3]))
775233
def _fix_review_dates(self, item):
        """"""

        for date_field in ['timestamp', 'createdOn', 'lastUpdated']:
            if date_field in item.keys():
                date_ts = item[date_field]
                item[date_field] = unixtime_to_datetime(date_ts).isoformat()

        if 'patchSets' in item.keys():
            for patch in item['patchSets']:
                pdate_ts = patch['createdOn']
                patch['createdOn'] = unixtime_to_datetime(pdate_ts).isoformat()

                if 'approvals' in patch:
                    for approval in patch['approvals']:
                        adate_ts = approval['grantedOn']
                        approval['grantedOn'] = unixtime_to_datetime(adate_ts).isoformat()

        if 'comments' in item.keys():
            for comment in item['comments']:
                cdate_ts = comment['timestamp']
                comment['timestamp'] = unixtime_to_datetime(cdate_ts).isoformat()
294671
def uncomment_or_update_or_append_line(filename, prefix, new_line, comment='#',
                                       keep_backup=True):
    '''
    '''
    return uua_local(filename, prefix, new_line, comment, keep_backup,
                     update_or_append_line=update_or_append_line)
227910
def mkchange(text0,text1,version,mtime):
  ""
  return Change(version,mtime,ucrc(text1),diff.word_diff(text0,text1))
416028
def ln_comment(self, ln):
        """"""
        if self.keep_lines:
            if not 1 <= ln <= len(self.original_lines) + 1:
                raise CoconutInternalException(
                    "out of bounds line number", ln,
                    "not in range [1, " + str(len(self.original_lines) + 1) + "]",
                )
            elif ln == len(self.original_lines) + 1:  # trim too large
                lni = -1
            else:
                lni = ln - 1
        if self.line_numbers and self.keep_lines:
            if self.minify:
                comment = str(ln) + " " + self.original_lines[lni]
            else:
                comment = " line " + str(ln) + ": " + self.original_lines[lni]
        elif self.keep_lines:
            if self.minify:
                comment = self.original_lines[lni]
            else:
                comment = " " + self.original_lines[lni]
        elif self.line_numbers:
            if self.minify:
                comment = str(ln)
            else:
                comment = " line " + str(ln)
        else:
            return ""
        return self.wrap_comment(comment, reformat=False)
250721
def set_comment(self,c):
        
        c = ' '+c.replace('-','').strip()+' '
        self.node.insert(0,etree.Comment(c))