-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Portando código do python 2 para 3 #13
base: master
Are you sure you want to change the base?
Conversation
packtrack/__init__.py
Outdated
from dhl_gm import DhlGmTracker | ||
from packtrack.correios import EncomendaRepository | ||
from packtrack.royal import RoyalMail | ||
from packtrack.dhl_gm import DhlGmTracker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usa imports relativos (from .correios import EncomendaRepository
). Para isso, precisa do from __future__ import absolute_import
no inicio do arquivo.
packtrack/correios.py
Outdated
@@ -15,7 +15,7 @@ def get(self, numero, auth=None): | |||
return func(numero, **kwargs) | |||
|
|||
def _init_scraper(self, backend): | |||
from scraping import CorreiosWebsiteScraper, CorreiosRastroService | |||
from packtrack.scraping import CorreiosWebsiteScraper, CorreiosRastroService |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mesma coisa, use import relativo.
packtrack/scraping.py
Outdated
@@ -50,7 +49,7 @@ def get_encomenda_info(self, numero): | |||
|
|||
if html: | |||
try: | |||
html = html.decode('latin-1') | |||
html = html.encode('latin-1') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Não tenho certeza se isso faz sentido.
.travis.yml
Outdated
@@ -1,5 +1,8 @@ | |||
language: python | |||
|
|||
python: | |||
- "3.6" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Precisa também rodar no python 2.7
.
removido encode latin-1 desnecessario adicionado ao travis python 2.7
@iurisilvio é OK fazer o merge? Minha preocupação é como isso pode refletir no postmon caso atualize tudo. |
Teria como rodarmos num ambiente a parte para simular?
Local mesmo.
|
Modificado a sintaxe dos imports
Modificado para bytes e strings ao longo do código
Atualizado requirements
BeautifulSoup agora pede um parser, utilizei o lxml por ser o sugerido pela documentaçao