Skip to content
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

removed references to deprecated python_utils file #417

Merged
merged 3 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Coding-style-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ If you use [Sublime Text](http://www.sublimetext.com/), consider installing the
## Python
- Consider using a frozenset or tuple to a list, if the data structure is not meant to be subsequently modified. This applies especially to constants.
- If you need to raise an Exception, just do `raise Exception` -- no need to define custom exceptions. We tend to use exceptions fairly sparingly, though.
- Do not use `str()` under any circumstances. Please try to use `python_utils.convert_to_bytes()` or the `b'` prefix for the strings used in webapp2\'s built-in methods or for strings used directly in NDB datastore models. If you need to cast ints/floats to strings, please use `python_utils.UNICODE()` instead. Avoid casting strings to other types of strings using str(), unicode(), etc. Also, there should be no need to prefix any string literals with b' or u', since all string literals in Python files are prefixed with `u'` by default (due to the import of unicode_literals at the top of the file).
- Otherwise, please follow the [Google Python style guide](https://github.com/google/styleguide/blob/gh-pages/pyguide.md). In particular:
- There should be two empty lines before any top-level class or function definition.
- It's OK for the initial documentation string to be more than one line long.
Expand Down
6 changes: 3 additions & 3 deletions Custom-Pylint-checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def test_finds_hello_world_assignment(self):
doc='Custom test')
temp_file = tempfile.NamedTemporaryFile()
filename = temp_file.name
with python_utils.open_file(filename, 'w') as tmp:
with open(filename, 'w') as tmp:
tmp.write('s = "Hello, world!"')
node.file = filename
node.path = filename
Expand All @@ -472,7 +472,7 @@ def test_finds_hello_world_func_call(self):
doc='Custom test')
temp_file = tempfile.NamedTemporaryFile()
filename = temp_file.name
with python_utils.open_file(filename, 'w') as tmp:
with open(filename, 'w') as tmp:
tmp.write('print("Hello, world!")')
node.file = filename
node.path = filename
Expand All @@ -499,7 +499,7 @@ def test_finds_hello_world_assignment(self):
temp_file = tempfile.NamedTemporaryFile()
filename = temp_file.name

with python_utils.open_file(filename, 'w') as tmp:
with open(filename, 'w') as tmp:
tmp.write("""
s = "Hello, world!"
print("Hello, world!")
Expand Down
20 changes: 10 additions & 10 deletions Find-the-right-code-to-change.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Next let's identify the backend files involved in handling updates to the user's
+ 'User experience exceeds maximum character limit: %s'
+ % feconf.MAX_BIO_LENGTH_IN_CHARS)
+ else:
+ python_utils.PRINT(
+ print(
+ 'DEBUG Controller received update: ' +
+ data)
```
Expand All @@ -218,7 +218,7 @@ Next let's identify the backend files involved in handling updates to the user's
"""
user_settings = get_user_settings(user_id, strict=True)
user_settings.user_experience = user_experience
python_utils.PRINT(
print(
'DEBUG: update_user_experience: ' + user_experience)
_save_user_settings(user_settings)
```
Expand All @@ -233,7 +233,7 @@ Next let's identify the backend files involved in handling updates to the user's
'User experience exceeds maximum character limit: %s'
% feconf.MAX_BIO_LENGTH_IN_CHARS)
else:
- python_utils.PRINT(
- print(
- 'DEBUG Controller received update: ' +
- data)
+ user_services.update_user_experience(self.user_id, data)
Expand Down Expand Up @@ -279,15 +279,15 @@ Next let's identify the backend files involved in handling updates to the user's
First, let's add a `user_experience` argument to the constructor, assign that argument to an instance field, and update the appropriate docstrings:

```diff
@@ -55,6 +55,7 @@ class UserSettings(python_utils.OBJECT):
@@ -55,6 +55,7 @@ class UserSettings:
a dataURI string.
default_dashboard: str or None. The default dashboard of the user.
user_bio: str. User-specified biography.
+ user_experience: str. User-specified experience description.
subject_interests: list(str) or None. Subject interests specified by
the user.
first_contribution_msec: float or None. The time in milliseconds when
@@ -77,7 +78,7 @@ class UserSettings(python_utils.OBJECT):
@@ -77,7 +78,7 @@ class UserSettings:
profile_picture_data_url=None, default_dashboard=None,
creator_dashboard_display_pref=(
constants.ALLOWED_CREATOR_DASHBOARD_DISPLAY_PREFS['CARD']),
Expand All @@ -296,15 +296,15 @@ Next let's identify the backend files involved in handling updates to the user's
preferred_language_codes=None, preferred_site_language_code=None,
preferred_audio_language_code=None, pin=None, display_alias=None,
deleted=False, created_on=None):
@@ -106,6 +107,7 @@ class UserSettings(python_utils.OBJECT):
@@ -106,6 +107,7 @@ class UserSettings:
creator_dashboard_display_pref: str. The creator dashboard of the
user.
user_bio: str. User-specified biography.
+ user_experience: str. User-specified experience description.
subject_interests: list(str) or None. Subject interests specified by
the user.
first_contribution_msec: float or None. The time in milliseconds
@@ -140,6 +142,7 @@ class UserSettings(python_utils.OBJECT):
@@ -140,6 +142,7 @@ class UserSettings:
self.default_dashboard = default_dashboard
self.creator_dashboard_display_pref = creator_dashboard_display_pref
self.user_bio = user_bio
Expand All @@ -317,7 +317,7 @@ Next let's identify the backend files involved in handling updates to the user's
Next, we need to update the `to_dict` function to include the `user_experience` field:

```diff
@@ -293,6 +296,7 @@ class UserSettings(python_utils.OBJECT):
@@ -293,6 +296,7 @@ class UserSettings:
'creator_dashboard_display_pref': (
self.creator_dashboard_display_pref),
'user_bio': self.user_bio,
Expand Down Expand Up @@ -369,7 +369,7 @@ Now that we have the user experience field added to all the models, we can updat
logging.error('Could not find user with id %s' % user_id)
raise Exception('User not found.')
+ if user_settings:
+ python_utils.PRINT(
+ print(
+ 'DEBUG get_user_settings experience: ' +
+ user_settings.user_experience)
return user_settings
Expand Down Expand Up @@ -401,7 +401,7 @@ Now that we have the user experience field added to all the models, we can updat
user_email_preferences.can_receive_subscription_email),
'subscription_list': subscription_list
})
+ python_utils.PRINT(self.values)
+ print(self.values)
self.render_json(self.values)
```

Expand Down
4 changes: 2 additions & 2 deletions Lint-Checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ We use linters to check our code for common errors or bad patterns. The Oppia li
python -m scripts.linters.run_lint_checks --files {{file paths}}
```

Separate file paths with spaces. For example, to lint `scripts/start.py` and `python_utils.py`, you could run this:
Separate file paths with spaces. For example, to lint `scripts/start.py` and `servers.py`, you could run this:

```console
python -m scripts.linters.run_lint_checks --files scripts/start.py python_utils.py
python -m scripts.linters.run_lint_checks --files scripts/start.py servers.py
```

4. To lint files in verbose mode, add the `--verbose` flag like this:
Expand Down
Loading