<commit_before>import re
import datetime

from pylons import config
from webhelpers.html import literal

import ckan.lib.helpers as h
import ckan.lib.base as base
import ckan.lib.dictization.model_dictize as model_dictize
import ckan.logic as logic
from ckan.logic.action.get import dashboard_activity_list
import ckan.model as model

from ckan.common import _, c

_check_access = logic.check_access

''' 
This file is a forced copy-pasta of ckan/lib/activity_streams.py due to the inability to overwrite activity streams.

Here we simply replace all occurrances of "dataset" with "datastream".

@TODO: Refactor everything - if possible...
'''

# Salvage what we do not need to rewrite.
from ckan.lib.activity_streams import get_snippet_actor, get_snippet_user, get_snippet_dataset, \
                                      get_snippet_tag, get_snippet_group, get_snippet_organization, \
                                      get_snippet_extra, get_snippet_resource, get_snippet_related_item, \
                                      get_snippet_related_type

# activity_stream_string_*() functions return translatable string
# representations of activity types, the strings contain placeholders like
# {user}, {dataset} etc. to be replaced with snippets from the get_snippet_*()
# functions above.

''' Replacements and salvaging in the order of appearance. '''

def activity_stream_string_added_tag(context, activity):
    return _("{actor} added the tag {tag} to the datastream {dataset}")

from ckan.lib.activity_streams import activity_stream_string_changed_group, activity_stream_string_changed_organization

def activity_stream_string_changed_package(context, activity):
    return _("{actor} updated the datastream {dataset}")

def activity_stream_string_changed_package_extra(context, activity):
    return _("{actor} changed the extra {extra} of the datastream {dataset}")

def activity_stream_string_changed_resource(context, activity):
    return _("{actor} updated the subscription {resource} in the datastream {dataset}")

from ckan.lib.activity_streams import activity_stream_string_changed_user

def activity_stream_string_changed_related_item(context, activity):
    if activity['data'].get('dataset'):
        return _("{actor} updated the {related_type} {related_item} of the "
                "datastream {dataset}")
    else:
        return _("{actor} updated the {related_type} {related_item}")

from ckan.lib.activity_streams import activity_stream_string_deleted_group, activity_stream_string_deleted_organization

def activity_stream_string_deleted_package(context, activity):
    return _("{actor} deleted the datastream {dataset}")

def activity_stream_string_deleted_package_extra(context, activity):
    return _("{actor} deleted the extra {extra} from the datastream {dataset}")

def activity_stream_string_deleted_resource(context, activity):
    return _("{actor} deleted the subscription {resource} from the datastream "
             "{dataset}")

from ckan.lib.activity_streams import activity_stream_string_new_group, activity_stream_string_new_organization

def activity_stream_string_new_package(context, activity):
    return _("{actor} created the datastream {dataset}")

def activity_stream_string_new_package_extra(context, activity):
    return _("{actor} added the extra {extra} to the datastream {dataset}")

def activity_stream_string_new_resource(context, activity):
    return _("{actor} added the subscription {resource} to the datastream {dataset}")

from ckan.lib.activity_streams import activity_stream_string_new_user

def activity_stream_string_removed_tag(context, activity):
    return _("{actor} removed the tag {tag} from the datastream {dataset}")

from ckan.lib.activity_streams import activity_stream_string_deleted_related_item, activity_stream_string_follow_dataset, \
                                      activity_stream_string_follow_user, activity_stream_string_follow_group

def activity_stream_string_new_related_item(context, activity):
    if activity['data'].get('dataset'):
        return _("{actor} added the {related_type} {related_item} to the "
                 "datastream {dataset}")
    else:<commit_msg>Display subscription (Resource) URLs on the activity stream instead of its obsolete name.<commit_after>import re
import datetime

from pylons import config
from webhelpers.html import literal
from webhelpers.html.tags import *
from routes import url_for

import ckan.lib.helpers as h
import ckan.lib.base as base
import ckan.lib.dictization.model_dictize as model_dictize
import ckan.logic as logic
from ckan.logic.action.get import dashboard_activity_list
import ckan.model as model

from ckan.common import _, c

_check_access = logic.check_access

''' 
This file is a forced copy-pasta of ckan/lib/activity_streams.py due to the inability to overwrite activity streams.

Here we simply replace all occurrances of "dataset" with "datastream".

@TODO: Refactor everything - if possible...
'''

# Salvage what we do not need to rewrite.
from ckan.lib.activity_streams import get_snippet_actor, get_snippet_user, get_snippet_dataset, \
                                      get_snippet_tag, get_snippet_group, get_snippet_organization, \
                                      get_snippet_extra, get_snippet_related_item, get_snippet_related_type

def get_snippet_resource(activity, detail):
    text = str(detail['data']['resource']['url'])
    url = url_for(controller='package',
                  action='resource_read',
                  id=activity['data']['package']['id'],
                  resource_id=detail['data']['resource']['id'])
    return link_to(text, url)


# activity_stream_string_*() functions return translatable string
# representations of activity types, the strings contain placeholders like
# {user}, {dataset} etc. to be replaced with snippets from the get_snippet_*()
# functions above.

''' Replacements and salvaging in the order of appearance. '''

def activity_stream_string_added_tag(context, activity):
    return _("{actor} added the tag {tag} to the datastream {dataset}")

from ckan.lib.activity_streams import activity_stream_string_changed_group, activity_stream_string_changed_organization

def activity_stream_string_changed_package(context, activity):
    return _("{actor} updated the datastream {dataset}")

def activity_stream_string_changed_package_extra(context, activity):
    return _("{actor} changed the extra {extra} of the datastream {dataset}")

def activity_stream_string_changed_resource(context, activity):
    return _("{actor} updated a subscription to {resource} in the datastream {dataset}")

from ckan.lib.activity_streams import activity_stream_string_changed_user

def activity_stream_string_changed_related_item(context, activity):
    if activity['data'].get('dataset'):
        return _("{actor} updated the {related_type} {related_item} of the "
                "datastream {dataset}")
    else:
        return _("{actor} updated the {related_type} {related_item}")

from ckan.lib.activity_streams import activity_stream_string_deleted_group, activity_stream_string_deleted_organization

def activity_stream_string_deleted_package(context, activity):
    return _("{actor} deleted the datastream {dataset}")

def activity_stream_string_deleted_package_extra(context, activity):
    return _("{actor} deleted the extra {extra} from the datastream {dataset}")

def activity_stream_string_deleted_resource(context, activity):
    return _("{actor} deleted the subscription {resource} from the datastream "
             "{dataset}")

from ckan.lib.activity_streams import activity_stream_string_new_group, activity_stream_string_new_organization

def activity_stream_string_new_package(context, activity):
    return _("{actor} created the datastream {dataset}")

def activity_stream_string_new_package_extra(context, activity):
    return _("{actor} added the extra {extra} to the datastream {dataset}")

def activity_stream_string_new_resource(context, activity):
    return _("{actor} added a subscription to {resource} to the datastream {dataset}")

from ckan.lib.activity_streams import activity_stream_string_new_user

def activity_stream_string_removed_tag(context, activity):
    return _("{actor} removed the tag {tag} from the datastream {dataset}")

from ckan.lib.activity_streams import activity_stream_string_deleted_related_item, activity_stream_string_follow_dataset, \
                                      activity_stream_string_follow_user, activity_stream_string_follow_group

def activity_stream_string_new_related_item(context, activity):
    if activity['data'].get('dataset'):
        return _("{actor} added the {related_type} {related_item} to the "
                 "datastream {dataset}")
    else:
{'fraction_non_alphanumeric': 0.08029197080291971, 'fraction_numerical': 0.0, 'mean_word_length': 4.917004048582996, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7638476', 'n_tokens_mistral': 2437, 'n_tokens_neox': 2446, 'n_words': 688}