<commit_before># Copyright  2015, Province of British Columbia
# License: https://github.com/bcgov/ckanext-bcgov/blob/master/license

import pprint
import logging
import ckan.lib.helpers
import ckan.model as model
import ckan.plugins.toolkit as toolkit
import ckan.logic as logic
from ckan.common import  (c, request)
from webhelpers.html import literal
import json
import urllib2
import ckan.lib.base as base
import pylons.config as config

import webhelpers.html.tools as wbtools
import ckanext.bcgov
from ckanext.bcgov.version import version
from ckanext.bcgov.util.git import get_short_commit_id

NotFound = logic.NotFound
get_action = logic.get_action
snippet = ckan.lib.helpers.snippet
url_for = ckan.lib.helpers.url_for

log = logging.getLogger('ckanext.bcgov')

abort = base.abort

from ckan.lib.helpers import unselected_facet_items

def remove_user_link(actor):
    return wbtools.strip_links(actor)

def get_suborgs(org_id):
    '''
    Returns the list of suborganizations of the given organization
    '''
    context = {'model': model, 'session':model.Session, 'user':c.user}

    org_model = context['model']

    group = org_model.Group.get(org_id)
    branches = group.get_children_groups(type="organization")

    suborgs = [branch.id for branch in branches]

    return suborgs

def get_org_parent(org_id):
    '''
    Returns the parent of an organization
    '''

    context = {'model': model, 'session':model.Session, 'user':c.user}
    org_model = context['model']

    group = org_model.Group.get(org_id)
    parent_org = group.get_parent_groups(type="organization")

    if parent_org and len(parent_org) > 0:
        return parent_org[0]
    else:
        return False

def get_suborg_sector(sub_org_id):
    '''
    Returns the sector that the sub_org with the input sub_org id belongs to.
    '''
    context = {'model': model, 'session':model.Session, 'user':c.user}
<commit_msg>Checking org_id arg in helper function, was causing errors when creating a new org<commit_after># Copyright  2015, Province of British Columbia
# License: https://github.com/bcgov/ckanext-bcgov/blob/master/license

import pprint
import logging
import ckan.lib.helpers
import ckan.model as model
import ckan.plugins.toolkit as toolkit
import ckan.logic as logic
from ckan.common import  (c, request)
from webhelpers.html import literal
import json
import urllib2
import ckan.lib.base as base
import pylons.config as config

import webhelpers.html.tools as wbtools
import ckanext.bcgov
from ckanext.bcgov.version import version
from ckanext.bcgov.util.git import get_short_commit_id

NotFound = logic.NotFound
get_action = logic.get_action
snippet = ckan.lib.helpers.snippet
url_for = ckan.lib.helpers.url_for

log = logging.getLogger('ckanext.bcgov')

abort = base.abort

from ckan.lib.helpers import unselected_facet_items

def remove_user_link(actor):
    return wbtools.strip_links(actor)

def get_suborgs(org_id):
    '''
    Returns the list of suborganizations of the given organization
    '''
    context = {'model': model, 'session':model.Session, 'user':c.user}

    org_model = context['model']

    group = org_model.Group.get(org_id)
    branches = group.get_children_groups(type="organization")

    suborgs = [branch.id for branch in branches]

    return suborgs

def get_org_parent(org_id):
    '''
    Returns the parent of an organization
    '''
    if not org_id:
        return False

    context = {'model': model, 'session':model.Session, 'user':c.user}
    org_model = context['model']

    group = org_model.Group.get(org_id)
    parent_org = group.get_parent_groups(type="organization")

    if parent_org and len(parent_org) > 0:
        return parent_org[0]
    else:
        return False

def get_suborg_sector(sub_org_id):
    '''
    Returns the sector that the sub_org with the input sub_org id belongs to.
    '''
    context = {'model': model, 'session':model.Session, 'user':c.user}

{'fraction_non_alphanumeric': 0.09676597911892029, 'fraction_numerical': 0.0035650623885918, 'mean_word_length': 4.121251629726206, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2203044', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1267, 'n_words': 340}