Skip to content

Commit

Permalink
fix utf8 header in documentation (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
yufeiminds authored Aug 21, 2019
1 parent 71777ff commit 6b03ea5
Show file tree
Hide file tree
Showing 13 changed files with 6 additions and 24 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

<p align="center">
<img src="https://ucloud-sdk.dl.ufileos.com/logos%2Flogo-mini.png" />
</p>
Expand Down
2 changes: 0 additions & 2 deletions docs/core.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

Core
====

Expand Down
2 changes: 0 additions & 2 deletions docs/helpers.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

Helpers
=======

Expand Down
2 changes: 0 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

UCloud SDK Python 2
===================

Expand Down
2 changes: 0 additions & 2 deletions docs/quick_start.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

QuickStart
==========

Expand Down
2 changes: 0 additions & 2 deletions docs/services.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

UCloud SDK Services
===================

Expand Down
2 changes: 0 additions & 2 deletions docs/usage.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

Usage
=====

Expand Down
2 changes: 0 additions & 2 deletions examples/two-tier/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

# UCloud SDK Two-Tier Example

## What is the goal
Expand Down
2 changes: 0 additions & 2 deletions examples/uhost/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

# UCloud SDK UHost Example

## What is the goal
Expand Down
4 changes: 1 addition & 3 deletions scripts/migrate/_migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class Config:


class Migrate(object):
UTF8_HEADER = '# -*- coding: utf-8 -*-\n\n'

default_plugins_classes = {
"py3to2": SDK3to2Transformer,
"doc": DocTransformer,
Expand Down Expand Up @@ -79,7 +77,7 @@ def run(self, source_path: str, output_path: str):
# convert destination code
output_code = source_code
for plugin in plugins:
output_code = self.UTF8_HEADER + plugin.convert(source_code)
output_code = plugin.convert(source_code)

# output to file
os.makedirs(os.path.dirname(result_path), exist_ok=True)
Expand Down
4 changes: 3 additions & 1 deletion scripts/migrate/_plugin_py3to2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@


class SDK3to2Transformer(ast.NodeTransformer):
UTF8_HEADER = '# -*- coding: utf-8 -*-\n\n'

def visit_Import(self, node):
is_typing = [alias for alias in node.names if alias.name == 'typing']
return None if is_typing else node
Expand Down Expand Up @@ -56,4 +58,4 @@ def visit_ClassDef(self, node):
def convert(self, source: str) -> str:
ast_node = ast.parse(source)
ast_node = self.visit(ast_node)
return astor.to_source(ast_node)
return self.UTF8_HEADER + astor.to_source(ast_node)
2 changes: 1 addition & 1 deletion tests/test_testing/test_utest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


@pytest.mark.skipif(env.is_ut(), reason=env.get_skip_reason())
def test_acc_pre_check(client):
def test_acc_pre_check(self, client):
assert str(client)
assert client.config.to_dict()
assert client.credential.to_dict()
Expand Down
2 changes: 1 addition & 1 deletion ucloud/core/utils/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
else:
import types

str = unicode
str = unicode # noqa: F821
string_types = types.StringTypes
from collections import Callable

0 comments on commit 6b03ea5

Please sign in to comment.