classes/xep.py
def req_xeplist(self):
		"""
		query and save the current xep list to reduce network bandwidth
		"""
		# check if etag header is present if not set local_etag to ""
		if os.path.isfile("./common/.etag"):
			with open("./common/.etag") as file:
				local_etag = file.read()
		else:
			local_etag = ""

		with requests.Session() as s:
			# head request the xeplist.xml
			s.headers.update({'Accept': 'application/xml'})
			head = s.head("https://xmpp.org/extensions/xeplist.xml")
			etag = head.headers['etag']

			# compare etag with local_etag if they match up no request is made
			if local_etag == etag:
				with open("./common/xeplist.xml", "r") as file:
					self.xeplist = Et.fromstring(file.read())

			# if the connection is not possible use cached xml if present
			elif os.path.isfile("./common/xeplist.xml") and head.status_code != 200:
				with open("./common/xeplist.xml", "r") as file:
					self.xeplist = Et.fromstring(file.read())

			# in any other case request the latest xml
			else:
				r = s.get("https://xmpp.org/extensions/xeplist.xml")
				r.encoding = 'utf-8'
				local_etag = head.headers['etag']

				with open("./common/xeplist.xml", "w") as file:
					file.write(r.content.decode())
					self.xeplist = Et.fromstring(r.content.decode())

				with open('./common/.etag', 'w') as string:
					string.write(local_etag)

		# populate xep comparison list
		for xep in self.xeplist.findall(".//*[@accepted='true']/number"):
			self.acceptedxeps.append(xep.text)

		query and save the current xep list to reduce network bandwidth
		
query and save the current xep list to reduce network bandwidth
query and save the current xep list to reduce network bandwidth
def req_xeplist(self):
		if os.path.isfile("./common/.etag"):
			with open("./common/.etag") as file:
				local_etag = file.read()
		else:
			local_etag = ""
		with requests.Session() as s:
			s.headers.update({'Accept': 'application/xml'})
			head = s.head("https://xmpp.org/extensions/xeplist.xml")
			etag = head.headers['etag']
			if local_etag == etag:
				with open("./common/xeplist.xml", "r") as file:
					self.xeplist = Et.fromstring(file.read())
			elif os.path.isfile("./common/xeplist.xml") and head.status_code != 200:
				with open("./common/xeplist.xml", "r") as file:
					self.xeplist = Et.fromstring(file.read())
			else:
				r = s.get("https://xmpp.org/extensions/xeplist.xml")
				r.encoding = 'utf-8'
				local_etag = head.headers['etag']
				with open("./common/xeplist.xml", "w") as file:
					file.write(r.content.decode())
					self.xeplist = Et.fromstring(r.content.decode())
				with open('./common/.etag', 'w') as string:
					string.write(local_etag)
		for xep in self.xeplist.findall(".//*[@accepted='true']/number"):
			self.acceptedxeps.append(xep.text)
def req_xeplist ( self ) : if os . path . isfile ( "./common/.etag" ) : with open ( "./common/.etag" ) as file : local_etag = file . read ( ) else : local_etag = "" with requests . Session ( ) as s : s . headers . update ( { 'Accept' : 'application/xml' } ) head = s . head ( "https://xmpp.org/extensions/xeplist.xml" ) etag = head . headers [ 'etag' ] if local_etag == etag : with open ( "./common/xeplist.xml" , "r" ) as file : self . xeplist = Et . fromstring ( file . read ( ) ) elif os . path . isfile ( "./common/xeplist.xml" ) and head . status_code != 200 : with open ( "./common/xeplist.xml" , "r" ) as file : self . xeplist = Et . fromstring ( file . read ( ) ) else : r = s . get ( "https://xmpp.org/extensions/xeplist.xml" ) r . encoding = 'utf-8' local_etag = head . headers [ 'etag' ] with open ( "./common/xeplist.xml" , "w" ) as file : file . write ( r . content . decode ( ) ) self . xeplist = Et . fromstring ( r . content . decode ( ) ) with open ( './common/.etag' , 'w' ) as string : string . write ( local_etag ) for xep in self . xeplist . findall ( ".//*[@accepted='true']/number" ) : self . acceptedxeps . append ( xep . text )
query and save the current xep list to reduce network bandwidth
query and save the current xep list to reduce network bandwidth
"""
		query and save the current xep list to reduce network bandwidth
		""" # check if etag header is present if not set local_etag to "" # head request the xeplist.xml # compare etag with local_etag if they match up no request is made # if the connection is not possible use cached xml if present # in any other case request the latest xml # populate xep comparison list
self