Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Conversation

@douglasfarinelli
Copy link
Contributor

No description provided.

@douglasfarinelli douglasfarinelli self-assigned this Jul 5, 2018
@douglasfarinelli douglasfarinelli changed the title Create AutoDiscover class in infra/module.py 🎉 Create AutoDiscover class in infra/module.py Jul 5, 2018
@douglasfarinelli douglasfarinelli force-pushed the df-create-autodiscover-modules branch from 09474d7 to f6fcc7f Compare July 5, 2018 22:06
aureliosaraiva
aureliosaraiva previously approved these changes Jul 6, 2018
continue

if (
obj.is_file()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💅 Tem uns espaços a mais aqui... acho que da pra alinhar o obj com and.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hahaha eu deixei para alinhar a condição... mas posso voltar também 🎉

return module_name[module_name.find(self.root):]

def __get_root_parts(self, path):
def get_root_parts(path):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depois me explica isso aqui? haha 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hahaha

Esse método serve para buscar o root package ou man package para fazer o import corretamente, pois nesse momento só tem o caminho absoluto do arquivo, como: /app/app/infra/event_bus/subscribes

O nome do módulo para funcionar deve ser: app.infra.event_bus.subscribes..., saka?

O que essa função faz é subir os niveis enquanto achar o __init__.py entre eles. Quando não achar significa que chegou no root da aplicação.

Esse root serve de aux para normalizar o nome do módulo, pois como disse, só tem o caminho absoluto dos arquivos e vem algo como já mencionei.

O normalize exclui tudo que vem antes do man package e aí o import fica limpo, como: app.infra.event_bus.subscribes.operations

Saka?

Isso foi feito para ser genérico, pois podemos chamar o autodiscover em qualquer lugar, como por exemplo em app.api para buscar as views. 🤔

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants