Skip to content
This repository has been archived by the owner on Jun 30, 2019. It is now read-only.

Re-organize #17

Merged
merged 5 commits into from
Jul 29, 2018
Merged

Re-organize #17

merged 5 commits into from
Jul 29, 2018

Conversation

cosven
Copy link
Owner

@cosven cosven commented Jul 26, 2018

重新组织代码结构

  1. 去掉 core 目录,将其目录下的移动到根目录
  2. 去掉 daemon 目录,同样的,将其内部模块移动到根目录

feeluown 有个 PR 依赖这个:https://github.com/cosven/FeelUOwn/pull/231

fuocore/app.py Outdated
self.gateway.publish(sentence + '\n', self.topic)


class CliMixin(object):
Copy link
Owner Author

Choose a reason for hiding this comment

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

这个其实不应该叫做 Mixin

Copy link
Owner Author

Choose a reason for hiding this comment

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

一般来说,Mixin 自身应该没有构造函数,如果有构造函数的话,那子类初始化会特别复杂(这个结论也不是特别确定)。

(看了下 cpython 中 ThreadingMixin 和 ConvertingMixin,他们都没有构造函数)

fuocore/app.py Outdated
self._live_lyric = live_lyric
self._live_lyric_publisher = live_lyric_publisher

def list_providers(self):
Copy link
Owner Author

@cosven cosven Jul 26, 2018

Choose a reason for hiding this comment

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

这个接口不应该有,让调用方直接调用 app.library.list()

fuocore/app.py Outdated
def list_providers(self):
return self.library.list()

def get_provider(self, name):
Copy link
Owner Author

Choose a reason for hiding this comment

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

同上

.format(len(songs), keyword))
return songs

def get_song(self, furi_str):
Copy link
Owner Author

@cosven cosven Jul 26, 2018

Choose a reason for hiding this comment

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

这个应该放到 protocol 中去实现,它和 f-url 相关
没有 protocol,理论上也就没有 uri 的概念?

这里的 uri 泛指类似这样的: fuo://netease/songs/1234 fuo://netease/artists/1234 fuo://netease/users/1234

identifier = result.path.split('/')[-1]
return provider.Song.get(identifier)

def list_songs(self, furi_str_list):
Copy link
Owner Author

Choose a reason for hiding this comment

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

同上

pass
finally:
pubsub_server.close()
event_loop.close()
Copy link
Owner Author

Choose a reason for hiding this comment

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

这一个文件 和 app.py 最好能再组织一下,现在看起来还挺复杂的样子

@@ -138,7 +139,13 @@ def handle(self, cmd):
self.app.player.toggle()

def play_song(self, song_furi):
self.app.play(song_furi)
result = urlparse(song_furi)
Copy link
Owner Author

@cosven cosven Jul 26, 2018

Choose a reason for hiding this comment

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

这个逻辑好像和 furi 逻辑重复了 -> 在 protocol 模块中应该要有个函数统一做这个(之前好像确实有个 furi.py)。

- 添加 `allow_get` 和 `allow_batch` 给 CLI 模式
- 计算文字宽度,让输出排列更整齐
区分 None 与空列表/空字符串的区别:None 代表该字段没有
被初始化,空列表或者空字符串表示初始化了,但是数据内容为空。
@cosven cosven merged commit d6b9eec into master Jul 29, 2018
@cosven cosven deleted the reorg branch July 29, 2018 12:03
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.

None yet

1 participant