Lines Matching refs:filename
503 files: A sequence of (name, filename, value) elements for data to be
519 for (key, filename, value) in files:
521 lines.append('Content-Disposition: form-data; name="%s"; filename="%s"' %
522 (key, filename))
523 lines.append('Content-Type: %s' % GetContentType(filename))
533 def GetContentType(filename):
534 """Helper to guess the content-type from the filename."""
535 return mimetypes.guess_type(filename)[0] or 'application/octet-stream'
625 def GetBaseFile(self, filename):
646 A dictionary that maps from filename to GetBaseFile's tuple. Filenames
653 unused, filename = line.split(':', 1)
654 # On Windows if a file has property changes its filename uses '\'
656 filename = filename.strip().replace('\\', '/')
657 files[filename] = self.GetBaseFile(filename)
665 def UploadFile(filename, file_id, content, is_binary, status, is_base):
674 (type, filename))
679 print "Uploading %s file for %s" % (type, filename)
681 form_fields = [("filename", filename),
692 [("data", filename, content)])
701 for filename in patches.keys():
702 base_content, new_content, is_binary, status = files[filename]
703 file_id_str = patches.get(filename)
709 UploadFile(filename, file_id, base_content, is_binary, status, True)
711 UploadFile(filename, file_id, new_content, is_binary, status, False)
713 def IsImage(self, filename):
714 """Returns true if the filename has an image extension."""
715 mimetype = mimetypes.guess_type(filename)[0]
844 def ReadFile(self, filename):
846 file = open(filename, 'rb')
854 def GetStatus(self, filename):
857 status = RunShell(["svn", "status", "--ignore-externals", filename])
859 ErrorExit("svn status returned no output for %s" % filename)
874 dirname, relfilename = os.path.split(filename)
879 ErrorExit("Failed to get status for %s." % filename)
898 def GetBaseFile(self, filename):
899 status = self.GetStatus(filename)
910 mimetype = RunShell(["svn", "propget", "svn:mime-type", filename],
914 if is_binary and self.IsImage(filename):
915 new_content = self.ReadFile(filename)
921 url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
923 # Don't change filename, it's needed later.
924 url = filename
938 if self.IsImage(filename):
942 new_content = self.ReadFile(filename)
944 url = "%s/%s@%s" % (self.svn_base, filename, self.rev_end)
960 url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
965 base_content = RunShell(["svn", "cat", filename],
971 url = "%s/%s@%s" % (self.svn_base, filename, self.rev_start)
973 url = filename
990 # Map of filename -> hash of base file.
1002 filename = None
1007 filename = match.group(1)
1008 svndiff.append("Index: %s\n" % filename)
1015 self.base_hashes[filename] = match.group(1)
1026 def GetBaseFile(self, filename):
1027 hash = self.base_hashes[filename]
1058 def _GetRelPath(self, filename):
1061 assert filename.startswith(self.subdir), filename
1062 return filename[len(self.subdir):].lstrip(r"\/")
1078 # the second filename.
1079 filename = m.group(2)
1080 svndiff.append("Index: %s" % filename)
1102 def GetBaseFile(self, filename):
1109 oldrelpath = relpath = self._GetRelPath(filename)
1118 # Moved/copied => considered as modified, use old filename to
1148 A list of 2-tuple (filename, text) where text is the svn diff output
1149 pertaining to filename.
1152 filename = None
1165 if temp_filename != filename:
1169 if filename and diff:
1170 patches.append((filename, ''.join(diff)))
1171 filename = new_filename
1176 if filename and diff:
1177 patches.append((filename, ''.join(diff)))
1184 Returns a list of [patch_key, filename] for each file.
1193 form_fields = [("filename", patch[0])]
1263 logging.basicConfig(format=("%(asctime).19s %(levelname)s %(filename)s:"