Explorar el Código

Put variables in strings behind gettext the function so they are properly recognized

Helmut Pozimski hace 12 años
padre
commit
cf80d24d0d
Se han modificado 4 ficheros con 32 adiciones y 32 borrados
  1. 8 8
      configuration.py
  2. 5 5
      stov.py
  3. 10 10
      subscription.py
  4. 9 9
      youtube.py

+ 8 - 8
configuration.py

@@ -89,7 +89,7 @@ class conf(object):
 				outputlevel="default", level=self.outputlevel, descriptor="stderr")
 		else:
 			for key in self.values.iterkeys():
-				printf(_("Writing value for %s" % key.upper()),
+				printf(_("Writing value for %s") % key.upper(),
 					outputlevel="verbose", level=self.outputlevel, descriptor="stderr")
 				self.configfile.write(key.upper() + "=" + self.values[key] + "\n")
 			self.configfile.close()
@@ -164,7 +164,7 @@ class conf(object):
 				"read, please check that the configuration file exists and is readable"),
 				outputlevel="default", level=self.outputlevel, descriptor="stderr")
 		for lines in self.configfile:
-			printf(_("Reading line %s" % lines.strip()),
+			printf(_("Reading line %s") % lines.strip(),
 				outputlevel="verbose", level=self.outputlevel, descriptor="stderr")
 			self.tmpline = lines.strip()
 			self.tmplist = self.tmpline.split("=")
@@ -187,8 +187,8 @@ class conf(object):
 		self.values["config_version"] = "0"
 		self.__currentdbversion = self.values["db_version"]
 		self.ReadConfig()
-		printf(_("Found running version: " + self.values["config_version"] + "\n" +
-			"Current version: " + str(self.__currentversion)),
+		printf(_("Found running version: ") + self.values["config_version"] + "\n" +
+			_("Current version: ") + str(self.__currentversion)),
 			outputlevel="verbose", level=self.outputlevel, descriptor="stderr")
 		if self.values["config_version"] == "0" \
 		or int(self.values["config_version"]) < self.__currentversion:
@@ -211,8 +211,8 @@ class conf(object):
 			outputlevel="verbose", level=self.outputlevel, descriptor="stderr")
 		self.values["db_version"] = "0"
 		self.ReadConfig()
-		printf(_("Found running database version: " + self.values["db_version"] +
-			"\n" + "Current version: " + str(self.__currentversion)),
+		printf(_("Found running database version: ") + self.values["db_version"] +
+			"\n" + _("Current version: ") + str(self.__currentversion)),
 			outputlevel="verbose", level=self.outputlevel, descriptor="stderr")
 		if self.values["db_version"] == "0" or \
 		int(self.values["db_version"]) < int(self.__currentdbversion):
@@ -280,7 +280,7 @@ class conf(object):
 				itag_value = 37
 			elif self.values["maxresolution"] == "3072p":
 				itag_value = 38
-		printf(_("Found value: %s" % itag_value),
+		printf(_("Found value: %s") % itag_value,
 			outputlevel="verbose", level=self.outputlevel, descriptor="stderr")
 		return itag_value
 
@@ -292,7 +292,7 @@ class conf(object):
 			"Please specify now :\n"), outputlevel="default", level=self.outputlevel,
 			descriptor="stdout")
 		for value in self.__explanations:
-			printf(_(self.__explanations[value] + " [" + self.values[value] + "]: "),
+			printf(self.__explanations[value] + " [" + self.values[value] + "]: ",
 				outputlevel="default", level=self.outputlevel,
 				descriptor="stdout")
 			self.__user_input = raw_input()

+ 5 - 5
stov.py

@@ -63,16 +63,16 @@ can be localized
 class MyOptionParser(OptionParser):
 	def error(self, msg):
 		if "invalid integer" in msg:
-			printf(_("option %s requires an integer value"
-						% msg.split()[1]),
-						outputlevel="default", descriptor="stderr")
+			printf(_("option %s requires an integer value")
+					% msg.split()[1],
+					outputlevel="default", descriptor="stderr")
 			self.exit()
 		elif "an argument" in msg:
-			printf(_("option %s requires an argument" % msg.split()[0]),
+			printf(_("option %s requires an argument") % msg.split()[0],
 				outputlevel="default", descriptor="stderr")
 			self.exit()
 		elif "no such" in msg:
-			printf(_("invalid option %s" % msg.split()[3]),
+			printf(_("invalid option %s") % msg.split()[3],
 				outputlevel="default", descriptor="stderr")
 			self.exit()
 		else:

+ 10 - 10
subscription.py

@@ -86,14 +86,14 @@ class sub(object):
 				outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
 
 		for i in self.__ParsedResponse.videos:
-			printf(_('Checking if video "%s" exists in the database' % i.title),
+			printf(_('Checking if video "%s" exists in the database') % i.title,
 				outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
 			self.__ytid = i.ytid
 			self.__videoquery = "SELECT id FROM videos WHERE ytid=?"
 			self.__cursor.execute(self.__videoquery, (self.__ytid,))
 			self.__tmpid = self.__cursor.fetchall()
 			if self.__tmpid == []:
-				printf(_("Video %s not found in database, inserting..." % i.title),
+				printf(_("Video %s not found in database, inserting...") % i.title,
 					outputlevel="verbose", level=self.__conf.outputlevel,
 					descriptor="stderr")
 				self.__query = "INSERT INTO videos (title, description, \
@@ -118,15 +118,15 @@ class sub(object):
 				"Please check permissions and try again."),
 				outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
 
-		printf(_("Getting all videos for subscription %s from database"
-			% self.__title), outputlevel="verbose", level=self.__conf.outputlevel,
+		printf(_("Getting all videos for subscription %s from database")
+			% self.__title, outputlevel="verbose", level=self.__conf.outputlevel,
 			descriptor="stderr")
 		self.__videoquerybysubscription = "SELECT id, title, description, \
 		ytid, downloaded, failcnt FROM videos WHERE subscription_id=?"
 		self.__cursor.execute(self.__videoquerybysubscription, (self.__ID,))
 		self.__videodata = self.__cursor.fetchall()
 		for i in self.__videodata:
-			printf(_("Got video %s" % i[1]),
+			printf(_("Got video %s") % i[1],
 				outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
 			self.__videos.append(youtube.video(id=i[0],
 			title=i[1], description=i[2], ytid=i[3],
@@ -174,10 +174,10 @@ class sub(object):
 		else:
 			self.__cursor = self.__connection.cursor()
 			self.__title = self.__ParsedResponse.title
-			printf(_("Found subscription title %s" % self.__title),
+			printf(_("Found subscription title %s") % self.__title,
 				outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
 			self.__directory = self.__name + "_" + self.__search.replace(" ", "_")
-			printf(_("Directory: %s" % self.__directory),
+			printf(_("Directory: %s") % self.__directory,
 				outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
 			self.__query = "INSERT INTO subscriptions (title, type, searchstring, \
 			directory, name) VALUES (?, ?, ?, ?, ?)"
@@ -193,7 +193,7 @@ class sub(object):
 		self.__cursor.execute(self.__query, self.__data)
 		self.__ID = self.__cursor.fetchone()
 		self.__ID = self.__ID[0]
-		printf(_("Subscription got internal ID %s" % self.__ID),
+		printf(_("Subscription got internal ID %s") % self.__ID,
 			outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
 		self.__connection.close()
 
@@ -243,7 +243,7 @@ class sub(object):
 			printf(_("None or invalid subscription type given, "
 						"please check the type option and try again"),
 				outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
-		printf(_("Constructed the following API URL: %s" % self.__APIURL),
+		printf(_("Constructed the following API URL: %s") % self.__APIURL,
 			outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
 
 	def CheckAndDelete(self):
@@ -259,7 +259,7 @@ class sub(object):
 		for item in self.__videos:
 			if item.ytid not in self.__id_list:
 				if item.delete() is True:
-					printf(_("Video %s deleted from the database!" % item.title),
+					printf(_("Video %s deleted from the database!") % item.title,
 					outputlevel="verbose", level=self.__conf.outputlevel,
 					descriptor="stdout")
 				else:

+ 9 - 9
youtube.py

@@ -41,7 +41,7 @@ class video(object):
 		self.__targetdir = self.__conf.values["downloaddir"] + "/" + directory
 		if os.access(self.__targetdir, os.F_OK) is False:
 			try:
-				printf(_("Creating directory %s" % self.__targetdir),
+				printf(_("Creating directory %s") % self.__targetdir,
 					outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
 				os.makedirs(self.__targetdir, 0750)
 			except os.error:
@@ -52,7 +52,7 @@ and can't be created. Please check your configuration and try again"),
 		os.chdir(self.__targetdir)
 		if self.downloaded == 0:
 			try:
-				printf(_('Downloading video "%s"' % self.title),
+				printf(_('Downloading video "%s"') % self.title,
 					outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
 				if self.__conf.outputlevel == "default":
 					subprocess.check_call(["youtube-dl", "--max-quality=%s"
@@ -71,13 +71,13 @@ and can't be created. Please check your configuration and try again"),
 				except sqlite3.OperationalError:
 					printf(_("The Video \"%s\" has been "
 								"downloaded but the status could not be updated in the database. "
-								"Please check what went wrong and correct it" % self.title),
+								"Please check what went wrong and correct it") % self.title,
 						outputlevel="default", level=self.__conf.outputlevel,
 							descriptor="stderr")
 				else:
 					self.__cursor = self.__database.cursor()
-					printf(_('Downloaded video "%s", updating database accordingly.'
-						% self.title), outputlevel="verbose", level=self.__conf.outputlevel,
+					printf(_('Downloaded video "%s", updating database accordingly.')
+						% self.title, outputlevel="verbose", level=self.__conf.outputlevel,
 						descriptor="stderr")
 					self.__query = "UPDATE videos SET downloaded ='1' WHERE id = ?"
 					self.__cursor.execute(self.__query, (self.__ID,))
@@ -87,14 +87,14 @@ and can't be created. Please check your configuration and try again"),
 			except subprocess.CalledProcessError:
 				printf(_("The video %s could not be downloaded "
 							"due to some problem with youtube-dl. If this happens to more than one "
-							"video, please check your youtube-dl version" % self.title),
+							"video, please check your youtube-dl version") % self.title,
 					outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
 				try:
 					self.__database = sqlite3.connect(self.__conf.dbpath)
 				except sqlite3.OperationalError:
 					printf(_("The Video \"%s\" has failed "
 								"downloading but the status could not be updated in the database. "
-								"Please check what went wrong and correct it" % self.title),
+								"Please check what went wrong and correct it") % self.title,
 						outputlevel="default", level=self.__conf.outputlevel,
 							descriptor="stderr")
 				else:
@@ -102,7 +102,7 @@ and can't be created. Please check your configuration and try again"),
 					self.failcnt = int(self.failcnt) + 1
 					if self.failcnt >= int(self.__conf.values["maxfails"]):
 						printf(_("The video \"%s\" has failed downloading too often, marking as"
-							" failed" % self.title), outputlevel="default",
+							" failed") % self.title, outputlevel="default",
 							level=self.__conf.outputlevel, descriptor="stderr")
 						self.__statement = "UPDATE videos SET downloaded = -1 WHERE id = ?"
 						self.__cursor.execute(self.__statement, (self.__ID,))
@@ -122,7 +122,7 @@ and can't be created. Please check your configuration and try again"),
 			self.__database = sqlite3.connect(self.__conf.dbpath)
 		except sqlite3.OperationalError:
 			printf(_("Could not connect to the database, please check settings and"
-				"permissions and try again"), outputlevel="default",
+				" permissions and try again"), outputlevel="default",
 				level=self.__conf.outputlevel, descriptor="stderr")
 			return False
 		else: