airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [airflow] dstandish commented on a change in pull request #6426: [AIRFLOW-5751] add get_uri method to Connection
Date Fri, 25 Oct 2019 09:41:48 GMT
dstandish commented on a change in pull request #6426: [AIRFLOW-5751] add get_uri method to
Connection
URL: https://github.com/apache/airflow/pull/6426#discussion_r338969769
 
 

 ##########
 File path: airflow/models/connection.py
 ##########
 @@ -145,6 +145,38 @@ def parse_from_uri(self, uri):
         if uri_parts.query:
             self.extra = json.dumps(dict(parse_qsl(uri_parts.query, keep_blank_values=True)))
 
+    def get_uri(self) -> str:
+        uri = '{}://'.format(self.conn_type.replace('_', '-'))
+
+        authority_block = ''
+        if self.login is not None:
+            authority_block += quote(self.login, safe='')
+
+        if self.password is not None:
+            authority_block += ':' + quote(self.password)
+
+        if authority_block > '':
+            authority_block += '@'
+
+            uri += authority_block
+
+        host_block = ''
+        if self.host:
+            host_block += quote(self.host, safe='')
+
+            if self.port:
+                host_block += ':{}'.format(self.port)
+
+            if self.schema:
 
 Review comment:
   Maybe best to go with simple alternative in comment above, and weaken the tests so they
don't care if empty login is parsed as '' or None?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message