text:
package com.hyh.plg.activity;

import android.app.Activity;
import android.app.Dialog;
import android.app.Fragment;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.ContextMenu;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;

import com.yly.mob.activity.transform.TransformIntent;
import com.yly.mob.android.BlockApplication;
import com.yly.mob.android.BlockEnv;
import com.yly.mob.hook.instrumentation.ApplicationInstrumentation;
import com.yly.mob.service.BlockServiceServer;
import com.yly.mob.utils.Logger;

/**
 * Created by tangdongwei on 2018/5/14.
 */

public class ActivityProxyInner2 extends Activity {

    private IActivity activityImpl = new BaseProxyActivity();
    private boolean mToBeRecycleImmediately = false;
    private boolean mTrimMemory = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Integer hashCode = hashCode();
        Logger.i("--------------ActivityProxyInner2 running----------------- : " + hashCode);

        ActivityProxyImpl.fixInnerActivityContext(this);
        //先修复intent(序列化问题)要紧,不然后面的操作一旦触发序列化会有问题
        ActivityProxyImpl.fixActivityIntent(this);

        ActivityLaunchRecord.recordActivityLaunchInfo(this);

        IActivity activityProxyImpl = ActivityProxyImpl.getActivityProxyImpl(this);
        if (activityProxyImpl != null) {
            activityProxyImpl.attach(this);
            activityImpl = activityProxyImpl;
        } else {
            activityImpl = new BaseProxyActivity();
        }
        activityImpl.onBeforeCreate(savedInstanceState);
        super.onCreate(savedInstanceState);
        activityImpl.onAfterCreate(savedInstanceState);
    }

    @Override
    public void onStart() {
        Logger.v("IN ActivityProxyInner2, onStart()");
        super.onStart();
        activityImpl.onStart();
    }

    @Override
    public void onRestart() {
        Logger.v("IN ActivityProxyInner2, onRestart()");
        super.onRestart();
        activityImpl.onRestart();
    }

    @Override
    public void onResume() {
        Logger.v("IN ActivityProxyInner2, onResume()");
        mToBeRecycleImmediately = false;
        mTrimMemory = false;
        super.onResume();
        activityImpl.onResume();
    }

    @Override
    public void onNewIntent(Intent intent) {
        Logger.v("IN ActivityProxyInner2, onNewIntent(Intent intent)");
        super.onNewIntent(intent);
        activityImpl.onNewIntent(intent);
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        Logger.v("IN ActivityProxyInner2, onSaveInstanceState(Bundle outState)");
//        super.onSaveInstanceState(outState);
        mToBeRecycleImmediately = true;
        activityImpl.onSaveInstanceState(outState);
    }

    @Override
    public void onPause() {
        Logger.v("IN ActivityProxyInner2, onPause()");
        super.onPause();
        activityImpl.onPause();
    }

    @Override
    public void onStop() {
        Logger.v("IN ActivityProxyInner2, onStop()");
        super.onStop();
        activityImpl.onStop();
    }

    @Override
    public void onDestroy() {
        ActivityLaunchRecord.removeActivityLaunchInfo(this);
        Integer hashCode = hashCode();
        Logger.i("--------------ActivityProxyInner2 onDestroy----------------- : " + hashCode);
        super.onDestroy();
        activityImpl.onDestroy();
        activityImpl = new BaseProxyActivity();
        //finish();
        if (mToBeRecycleImmediately) {
            /*HookInstaller hookInstaller = new HookInstaller();
            hookInstaller.install();*/
            ApplicationInstrumentation.getInstance().requestReplaceInstrumentation();
            if (mTrimMemory) {
                finish();
            }
        }
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        Logger.v("IN ActivityProxyInner2, onConfigurationChanged(Configuration newConfig)");
        super.onConfigurationChanged(newConfig);
        activityImpl.onConfigurationChanged(newConfig);
    }

    @Override
    public void onLowMemory() {
        Logger.v("IN ActivityProxyInner2, onLowMemory()");
        super.onLowMemory();
        activityImpl.onLowMemory();
    }

    @Override
    public void onTrimMemory(int level) {
        Logger.v("IN ActivityProxyInner2, onTrimMemory(int level)");
        super.onTrimMemory(level);
        mTrimMemory = true;
        activityImpl.onTrimMemory(level);
    }

    @Override
    public void onAttachFragment(Fragment fragment) {
        Logger.v("IN ActivityProxyInner2, onAttachFragment(Fragment fragment)");
        super.onAttachFragment(fragment);
        activityImpl.onAttachFragment(fragment);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        Logger.v("IN ActivityProxyInner2, onActivityResult(int requestCode, int resultCode, Intent data)");
        super.onActivityResult(requestCode, resultCode, data);
        activityImpl.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        Logger.v("IN ActivityProxyInner2, onRestoreInstanceState(Bundle savedInstanceState)");
//        super.onRestoreInstanceState(savedInstanceState);
        activityImpl.onRestoreInstanceState(savedInstanceState);
    }

    @Override
    protected void onUserLeaveHint() {
        Logger.v("IN ActivityProxyInner2, onUserLeaveHint()");
        super.onUserLeaveHint();
        activityImpl.onUserLeaveHint();
    }

    @Override
    public void onUserInteraction() {
        Logger.v("IN ActivityProxyInner2, onUserInteraction()");
        super.onUserInteraction();
        activityImpl.onUserInteraction();
    }

    @Override
    public void onBackPressed() {
        Logger.v("IN ActivityProxyInner2, onBackPressed()");
        if (!activityImpl.onBackPressed()) {
            super.onBackPressed();
        }
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Logger.v("IN ActivityProxyInner2, onTouchEvent(MotionEvent event)");
        return activityImpl.onTouchEvent(event) || super.onTouchEvent(event);
    }

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        Logger.v("IN ActivityProxyInner2, onKeyUp(int keyCode, KeyEvent event)");
        return activityImpl.onKeyUp(keyCode, event) || super.onKeyUp(keyCode, event);
    }

    @Override
    public void onWindowAttributesChanged(WindowManager.LayoutParams params) {
        Logger.v("IN ActivityProxyInner2, onWindowAttributesChanged(WindowManager.LayoutParams params)");
        super.onWindowAttributesChanged(params);
        activityImpl.onWindowAttributesChanged(params);
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        Logger.v("IN ActivityProxyInner2, onWindowFocusChanged(boolean hasFocus)");
        super.onWindowFocusChanged(hasFocus);
        activityImpl.onWindowFocusChanged(hasFocus);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        Logger.v("IN ActivityProxyInner2, onCreateOptionsMenu(Menu menu)");
        return activityImpl.onCreateOptionsMenu(menu) || super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        Logger.v("IN ActivityProxyInner2, onOptionsItemSelected(MenuItem item)");
        return activityImpl.onOptionsItemSelected(item) || super.onOptionsItemSelected(item);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        Logger.v("IN ActivityProxyInner2, onKeyDown(int keyCode, KeyEvent event)");
        return activityImpl.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
    }

    @Override
    public boolean onKeyLongPress(int keyCode, KeyEvent event) {
        Logger.v("IN ActivityProxyInner2, onKeyLongPress(int keyCode, KeyEvent event)");
        return activityImpl.onKeyLongPress(keyCode, event) || super.onKeyLongPress(keyCode, event);
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        Logger.v("IN ActivityProxyInner2, dispatchKeyEvent(KeyEvent event)");
        return activityImpl.dispatchKeyEvent(event) || super.dispatchKeyEvent(event);
    }

    /*
     **********
     */
    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        Logger.v("IN ActivityProxyInner2, dispatchTouchEvent(MotionEvent ev)");
        return activityImpl.dispatchTouchEvent(ev) || super.dispatchTouchEvent(ev);
    }

    @Override
    public boolean dispatchTrackballEvent(MotionEvent motionEvent) {
        Logger.v("IN ActivityProxyInner2, dispatchTrackballEvent(MotionEvent motionEvent)");
        return activityImpl.dispatchTrackballEvent(motionEvent) || super.dispatchTrackballEvent(motionEvent);
    }

    @Override
    protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
        Logger.v("IN ActivityProxyInner2, onApplyThemeResource(Resources.Theme theme, int resid, boolean first)");
        super.onApplyThemeResource(theme, resid, first);
        activityImpl.onApplyThemeResource(theme, resid, first);
    }

    @Override
    protected void onChildTitleChanged(Activity childActivity, CharSequence title) {
        Logger.v("IN ActivityProxyInner2, onChildTitleChanged(Activity childActivity, CharSequence title)");
        super.onChildTitleChanged(childActivity, title);
        activityImpl.onChildTitleChanged(childActivity, title);
    }

    @Override
    public void onContentChanged() {
        Logger.v("IN ActivityProxyInner2, onContentChanged()");
        super.onContentChanged();
        activityImpl.onContentChanged();
    }

    @Override
    public boolean onContextItemSelected(MenuItem item) {
        Logger.v("IN ActivityProxyInner2, onContextItemSelected(MenuItem item)");
        return activityImpl.onContextItemSelected(item) || super.onContextItemSelected(item);
    }

    @Override
    public void onContextMenuClosed(Menu menu) {
        Logger.v("IN ActivityProxyInner2, onContextMenuClosed(Menu menu)");
        super.onContextMenuClosed(menu);
        activityImpl.onContextMenuClosed(menu);
    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
        Logger.v("IN ActivityProxyInner2, onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo)");
        super.onCreateContextMenu(menu, v, menuInfo);
        activityImpl.onCreateContextMenu(menu, v, menuInfo);
    }

    @Override
    public CharSequence onCreateDescription() {
        Logger.v("IN ActivityProxyInner2, onCreateDescription()");
        CharSequence charSequence = activityImpl.onCreateDescription();
        return charSequence != null ? charSequence : super.onCreateDescription();
    }

    @Override
    protected Dialog onCreateDialog(int id) {
        Logger.v("IN ActivityProxyInner2, onCreateDialog(int id)");
        Dialog dialog = activityImpl.onCreateDialog(id);
        return dialog != null ? dialog : super.onCreateDialog(id);
    }

    @Override
    public boolean onCreatePanelMenu(int featureId, Menu menu) {
        Logger.v("IN ActivityProxyInner2, onCreatePanelMenu(int featureId, Menu menu)");
        return activityImpl.onCreatePanelMenu(featureId, menu) || super.onCreatePanelMenu(featureId, menu);
    }

    @Override
    public View onCreatePanelView(int featureId) {
        Logger.v("IN ActivityProxyInner2, onCreatePanelView(int featureId)");
        View view = activityImpl.onCreatePanelView(featureId);
        return view != null ? view : super.onCreatePanelView(featureId);
    }

    @Override
    public boolean onCreateThumbnail(Bitmap outBitmap, Canvas canvas) {
        Logger.v("IN ActivityProxyInner2, onCreateThumbnail(Bitmap outBitmap, Canvas canvas)");
        return activityImpl.onCreateThumbnail(outBitmap, canvas) || super.onCreateThumbnail(outBitmap, canvas);
    }

    @Override
    public View onCreateView(String name, Context context, AttributeSet attrs) {
        Logger.v("IN ActivityProxyInner2, onCreateView(String name, Context context, AttributeSet attrs)");
        View view = activityImpl.onCreateView(name, context, attrs);
        return view != null ? view : super.onCreateView(name, context, attrs);
    }

    @Override
    public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
        Logger.v("IN ActivityProxyInner2, onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)");
        return activityImpl.onKeyMultiple(keyCode, repeatCount, event) || super.onKeyMultiple(keyCode, repeatCount, event);
    }

    @Override
    public boolean onMenuItemSelected(int featureId, MenuItem item) {
        Logger.v("IN ActivityProxyInner2, onMenuItemSelected(int featureId, MenuItem item)");
        return activityImpl.onMenuItemSelected(featureId, item) || super.onMenuItemSelected(featureId, item);
    }

    @Override
    public boolean onMenuOpened(int featureId, Menu menu) {
        Logger.v("IN ActivityProxyInner2, onMenuOpened(int featureId, Menu menu)");
        return activityImpl.onMenuOpened(featureId, menu) || super.onMenuOpened(featureId, menu);
    }

    @Override
    public void onOptionsMenuClosed(Menu menu) {
        Logger.v("IN ActivityProxyInner2, onOptionsMenuClosed(Menu menu)");
        super.onOptionsMenuClosed(menu);
        activityImpl.onOptionsMenuClosed(menu);
    }

    @Override
    public void onPanelClosed(int featureId, Menu menu) {
        Logger.v("IN ActivityProxyInner2, onPanelClosed(int featureId, Menu menu)");
        super.onPanelClosed(featureId, menu);
        activityImpl.onPanelClosed(featureId, menu);
    }

    @Override
    protected void onPostCreate(Bundle savedInstanceState) {
        Logger.v("IN ActivityProxyInner2, onPostCreate(Bundle savedInstanceState)");
        super.onPostCreate(savedInstanceState);
        activityImpl.onPostCreate(savedInstanceState);
    }

    @Override
    protected void onPostResume() {
        Logger.v("IN ActivityProxyInner2, onPostResume()");
        super.onPostResume();
        activityImpl.onPostResume();
    }

    @Override
    protected void onPrepareDialog(int id, Dialog dialog) {
        Logger.v("IN ActivityProxyInner2, onPrepareDialog(int id, Dialog dialog)");
        super.onPrepareDialog(id, dialog);
        activityImpl.onPrepareDialog(id, dialog);
    }

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        Logger.v("IN ActivityProxyInner2, onPrepareOptionsMenu(Menu menu)");
        return activityImpl.onPrepareOptionsMenu(menu) || super.onPrepareOptionsMenu(menu);
    }

    @Override
    public boolean onPreparePanel(int featureId, View view, Menu menu) {
        Logger.v("IN ActivityProxyInner2, onPreparePanel(int featureId, View view, Menu menu)");
        return activityImpl.onPreparePanel(featureId, view, menu) || super.onPreparePanel(featureId, view, menu);
    }

    @Override
    public Object onRetainNonConfigurationInstance() {
        Logger.v("IN ActivityProxyInner2, onRetainNonConfigurationInstance()");
        Object result = activityImpl.onRetainNonConfigurationInstance();
        return result != null ? result : super.onRetainNonConfigurationInstance();
    }

    @Override
    public boolean onSearchRequested() {
        Logger.v("IN ActivityProxyInner2, onSearchRequested()");
        return activityImpl.onSearchRequested() || super.onSearchRequested();
    }

    @Override
    protected void onTitleChanged(CharSequence title, int color) {
        Logger.v("IN ActivityProxyInner2, onTitleChanged(CharSequence title, int color)");
        super.onTitleChanged(title, color);
        activityImpl.onTitleChanged(title, color);
    }

    @Override
    public boolean onTrackballEvent(MotionEvent event) {
        Logger.v("IN ActivityProxyInner2, onTrackballEvent(MotionEvent event)");
        return activityImpl.onTrackballEvent(event) || super.onTrackballEvent(event);
    }

    @Override
    public void finish() {
        Logger.v("IN ActivityProxyInner2, finish()");
        super.finish();
        activityImpl.onFinish();
    }

    /*
     *************
     */

    @Override
    public Context getApplicationContext() {
        Context context = null;
        if (activityImpl != null) {
            context = activityImpl.onGetApplicationContext();
        }
        context = (context == null ? BlockApplication.blockApplicationContext : context);
        Logger.v("IN ActivityProxyInner2, getApplicationContext(), context=" + context);
        return context;
    }

    @Override
    public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
        Logger.v("IN ActivityProxyInner2, startActivityForResult(Intent intent, int requestCode, Bundle options)");
        //startActivityForResult事件先传递给插件,如果插件不消耗,这里再执行;如果插件消耗,则不再执行
        if (!activityImpl.onStartActivityForResult(intent, requestCode, options)) {
            TransformIntent transformIntent = ActivityProxyImpl.transformIntentForActivityProxy(intent);
            if (transformIntent == null) {
                super.startActivityForResult(intent, requestCode, options);
            } else {
                if (transformIntent.transformIntent == null) {
                    return;
                }
                /*HookInstaller hookInstaller = new HookInstaller();
                hookInstaller.install();*/
                ApplicationInstrumentation.getInstance().requestReplaceInstrumentation();
                super.startActivityForResult(transformIntent.transformIntent, requestCode, options);
            }
        }
    }

    @Override
    public void setTheme(int resid) {
        if (activityImpl != null && activityImpl.setTheme(resid)) return;
        super.setTheme(resid);
    }

    @Override
    public void setRequestedOrientation(int requestedOrientation) {
        if (activityImpl != null && activityImpl.setRequestedOrientation(requestedOrientation)) return;
        super.setRequestedOrientation(requestedOrientation);
    }

    @Override
    public PackageManager getPackageManager() {
        Logger.v("IN ActivityProxyInner2, getPackageManager()");
        return BlockApplication.blockApplicationContext.getPackageManager();
    }

    @SuppressWarnings("all")
    @Override
    public LayoutInflater getLayoutInflater() {
        return BlockApplication.blockApplication.getLayoutInflater();
    }

    /*
     ********************************** 处理service BEGIN ********************************
     */
    @Override
    public ComponentName startService(Intent service) {
        if (!BlockEnv.isServiceProxyEnable()) {
            return super.startService(service);
        }
        ComponentName componentName = BlockServiceServer.getInstance(getApplicationContext()).startService(service);
        return componentName == null ? super.startService(service) : componentName;
    }

    @Override
    public ComponentName startForegroundService(Intent service) {
        if (!BlockEnv.isServiceProxyEnable()) {
            return super.startForegroundService(service);
        }
        ComponentName componentName = BlockServiceServer.getInstance(getApplicationContext()).startForegroundService(service);
        return componentName == null ? super.startForegroundService(service) : componentName;
    }

    @Override
    public boolean stopService(Intent name) {
        if (!BlockEnv.isServiceProxyEnable()) {
            return super.stopService(name);
        }
        return BlockServiceServer.getInstance(getApplicationContext()).stopService(name) || super.stopService(name);
    }

    @Override
    public boolean bindService(Intent service, ServiceConnection conn, int flags) {
        if (!BlockEnv.isServiceProxyEnable()) {
            return super.bindService(service, conn, flags);
        }
        return BlockServiceServer.getInstance(getApplicationContext()).bindService(service, conn, flags) || super.bindService(service, conn, flags);
    }

    @Override
    public void unbindService(ServiceConnection conn) {
        if (BlockServiceServer.getInstance(getApplicationContext()).unbindService(conn)) return;
        try {
            super.unbindService(conn);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /*
     ********************************** 处理service END ********************************
     */
}


text:
from __future__ import unicode_literals

from django.db import migrations

from bluebottle.utils.utils import update_group_permissions

def add_group_permissions(apps, schema_editor):
    group_perms = {
        'Staff': {
            'perms': (
                'change_projectlocation',
            )
        },
    }

    update_group_permissions('projects', group_perms, apps)

class Migration(migrations.Migration):

    dependencies = [
        ('projects', '0069_auto_20180316_1553'),
    ]

    operations = [
            migrations.RunPython(add_group_permissions)
    ]

redpajama_set_name: RedPajamaGithub


text:
class Contracto::Stats

  NA_TEXT = 'N/A'

  class << self
    attr_accessor :all_contracts

    def used_contracts
      @used_contracts ||= []
    end

    def used_responses
      @used_responses ||= []
    end

    def all_responses
      @all_responses ||= all_contracts.map(&:responses).map(&:count).inject(&:+)
    end

    def contracts_usage
      return NA_TEXT if all_contracts.size.zero?

      (used_contracts.size/all_contracts.size.to_f).round(2)
    end

    def responses_usage
      return NA_TEXT if all_responses.size.zero?

      (used_responses.size/all_responses.size.to_f).round(2)
    end

    def contracts_stats_summary
      "contracts usage: #{used_contracts.size}/#{all_contracts.size} (#{contracts_usage * 100}%)"
    end

    def responses_stats_summary
      "examples usage: #{used_responses.size}/#{all_responses.size} (#{responses_usage * 100}%)"
    end

    def summary
      length = contracts_stats_summary.length
      [
        'stats'.center(length, '-'),
        contracts_stats_summary,
        responses_stats_summary,
        ('-' * length) + ' '
      ].join("\n")
    end
  end
end


text:
<Project _id="id34" name="test_counter" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" statementCount="3" statementIndex="0" xsi:noNamespaceSchemaLocation="SFC.xsd">
	<BasicType te="id4a id52" _id="id43" name="double" statementIndex="1"/>
	<Program _id="id45" filename="test_counter_sl" stateCount="0" numInstance="1" statementCount="2" statementIndex="2">
		<Class _id="id44" name="test_counter_54_class" statementCount="3" statementIndex="0">
			<Function _id="id48" name="test_counter_54_main" scope="" argCount="2" returnType="void" statementCount="1" statementIndex="1">
				<Arg dt="id47" _id="id49" ptr="true" ref="id58" name="context" size="1" type="" argIndex="0"/>
				<Arg dt="id43" _id="id4a" ptr="true" ref="id56" name="Out1_2" size="1" type="double" argIndex="2"/>
				<FunctionCall _id="id54" callee="id4f" argCount="2" libFuncName="Counter_main" statementIndex="0">
					<ArgVal _id="id53" arg="id4e" val="0" argIndex="0">
						<BinaryExprs op="." _id="id62">
							<ArgDeclRef _id="id58" unres="" argdecl="id49" __child_as="leftexpr"/>
							<ArgDeclRef _id="id59" unres="" argdecl="id57" __child_as="rightexpr"/>
						</BinaryExprs>
					</ArgVal>
					<ArgVal _id="id55" arg="id52" val="" argIndex="1">
						<ArgDeclRef _id="id56" unres="" argdecl="id4a"/>
					</ArgVal>
				</FunctionCall>
			</Function>
			<Function _id="id5a" name="test_counter_54_init" scope="" argCount="1" returnType="void" statementCount="1" statementIndex="2">
				<Arg dt="id47" _id="id5b" ptr="true" ref="id5e" name="context" size="1" type="" argIndex="0"/>
				<FunctionCall _id="id60" callee="id5d" argCount="1" libFuncName="" statementIndex="0">
					<ArgVal _id="id61" arg="id5c" val="" argIndex="0">
						<BinaryExprs op="." _id="id63">
							<ArgDeclRef _id="id5f" unres="" argdecl="id57" __child_as="rightexpr"/>
							<ArgDeclRef _id="id5e" unres="" argdecl="id5b" __child_as="leftexpr"/>
						</BinaryExprs>
					</ArgVal>
				</FunctionCall>
			</Function>
			<Struct te="id49 id5b" _id="id47" name="test_counter_54_context" memberCount="1" statementIndex="0">
				<LocalVar dt="id4d" _id="id57" ref="id59 id5f" name="Counter_member0" size="1" type="" scope="" initial="" statementIndex="0"/>
			</Struct>
		</Class>
		<Class _id="id46" name="Counter" statementCount="3" statementIndex="1">
			<Function _id="id4f" name="Counter_main" scope="" caller="id54" argCount="2" returnType="void" statementCount="-1" statementIndex="1">
				<Arg dt="id4d" _id="id4e" ptr="true" val="id53" name="context" size="1" type="" argIndex="0"/>
				<Arg dt="id43" _id="id52" ptr="true" val="id55" name="ctr_1" size="1" type="" argIndex="1"/>
			</Function>
			<Function _id="id5d" name="Counter_init" scope="" caller="id60" argCount="1" returnType="void" statementCount="-1" statementIndex="2">
				<Arg dt="id4d" _id="id5c" ptr="true" val="id61" name="context" size="1" type="" argIndex="0"/>
			</Function>
			<Struct te="id4e id57 id5c" _id="id4d" name="Counter_context" memberCount="-1" statementIndex="0"/>
		</Class>
	</Program>
</Project>


text:
"""Adds config flow for Trafikverket Weather integration."""
from __future__ import annotations

from pytrafikverket.trafikverket_weather import TrafikverketWeather
import voluptuous as vol

from homeassistant import config_entries
from homeassistant.const import CONF_API_KEY
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv

from .const import CONF_STATION, DOMAIN

class TVWeatherConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
    """Handle a config flow for Trafikverket Weatherstation integration."""

    VERSION = 1

    entry: config_entries.ConfigEntry

    async def validate_input(self, sensor_api: str, station: str) -> str:
        """Validate input from user input."""
        web_session = async_get_clientsession(self.hass)
        weather_api = TrafikverketWeather(web_session, sensor_api)
        try:
            await weather_api.async_get_weather(station)
        except ValueError as err:
            return str(err)
        return "connected"

    async def async_step_user(
        self, user_input: dict[str, str] | None = None
    ) -> FlowResult:
        """Handle the initial step."""
        errors = {}

        if user_input is not None:
            name = user_input[CONF_STATION]
            api_key = user_input[CONF_API_KEY]
            station = user_input[CONF_STATION]

            validate = await self.validate_input(api_key, station)
            if validate == "connected":
                return self.async_create_entry(
                    title=name,
                    data={
                        CONF_API_KEY: api_key,
                        CONF_STATION: station,
                    },
                )
            if validate == "Source: Security, message: Invalid authentication":
                errors["base"] = "invalid_auth"
            elif validate == "Could not find a weather station with the specified name":
                errors["base"] = "invalid_station"
            elif validate == "Found multiple weather stations with the specified name":
                errors["base"] = "more_stations"
            else:
                errors["base"] = "cannot_connect"

        return self.async_show_form(
            step_id="user",
            data_schema=vol.Schema(
                {
                    vol.Required(CONF_API_KEY): cv.string,
                    vol.Required(CONF_STATION): cv.string,
                }
            ),
            errors=errors,
        )


text:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
<sun-web-app error-url="">
  <context-root>/SWAGr</context-root>
  <jsp-config>
    <property name="keepgenerated" value="true">
      <description>Keep a copy of the generated servlet class' java code.</description>
    </property>
  </jsp-config>
</sun-web-app>


text:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { FooterComponent } from './footer.component';

@NgModule({
    imports: [ RouterModule, CommonModule ],
    declarations: [ FooterComponent ],
    exports: [ FooterComponent ]
})

export class FooterModule {}


text:
@implementation Homework

+ (NSDictionary *)modelCustomPropertyMapper {
    return @{@"courseID":@"courseId",@"exerciseID":@"exerciseId"};
}

@end


text:
package in.twizmwaz.openuhc.module;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Defines a setting for a module.
 */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Setting {

  /**
   * @return A unique, human-readable description of the setting
   */
  String value();

}


text:
cd server
nohup python sync.py&


text:
import re
import json
from datetime import time
from crispy_forms.bootstrap import StrictButton, InlineField
from crispy_forms.helper import FormHelper
from django import forms
from django.forms.forms import Form
from django.forms.fields import *
from crispy_forms import layout as crispy
from django.utils.safestring import mark_safe
from corehq.apps.hqwebapp.crispy import BootstrapMultiField
from corehq.apps.sms.models import FORWARD_ALL, FORWARD_BY_KEYWORD
from django.core.exceptions import ValidationError
from corehq.apps.sms.mixin import SMSBackend
from corehq.apps.reminders.forms import RecordListField, validate_time
from django.utils.translation import ugettext as _, ugettext_noop, ugettext_lazy
from corehq.apps.sms.util import get_available_backends
from corehq.apps.domain.models import DayTimeWindow
from dimagi.utils.django.fields import TrimmedCharField
from django.conf import settings

FORWARDING_CHOICES = (
    (FORWARD_ALL, ugettext_noop("All messages")),
    (FORWARD_BY_KEYWORD, ugettext_noop("All messages starting with a keyword")),
)

SMS_CONVERSATION_LENGTH_CHOICES = (
    (5, 5),
    (10, 10),
    (15, 15),
    (20, 20),
    (25, 25),
    (30, 30),
)

TIME_BEFORE = "BEFORE"
TIME_AFTER = "AFTER"
TIME_BETWEEN = "BETWEEN"

class SMSSettingsForm(Form):
    _cchq_is_previewer = False
    use_default_sms_response = BooleanField(required=False)
    default_sms_response = TrimmedCharField(required=False)
    use_custom_case_username = BooleanField(required=False)
    custom_case_username = TrimmedCharField(required=False)
    use_custom_message_count_threshold = BooleanField(required=False)
    custom_message_count_threshold = IntegerField(required=False)
    use_custom_chat_template = BooleanField(required=False)
    custom_chat_template = TrimmedCharField(required=False)
    use_restricted_sms_times = BooleanField(required=False)
    restricted_sms_times_json = CharField(required=False)
    use_sms_conversation_times = BooleanField(required=False)
    sms_conversation_times_json = CharField(required=False)
    sms_conversation_length = ChoiceField(
        choices=SMS_CONVERSATION_LENGTH_CHOICES,
        required=False,
    )
    filter_surveys_from_chat = BooleanField(required=False)
    show_invalid_survey_responses_in_chat = BooleanField(required=False)
    count_messages_as_read_by_anyone = BooleanField(required=False)

    def initialize_time_window_fields(self, initial, bool_field, json_field):
        time_window_json = [w.to_json() for w in initial]
        self.initial[json_field] = json.dumps(time_window_json)
        if len(initial) > 0:
            self.initial[bool_field] = True
        else:
            self.initial[bool_field] = False

    def __init__(self, *args, **kwargs):
        self._cchq_is_previewer = kwargs.pop("_cchq_is_previewer", False)
        super(SMSSettingsForm, self).__init__(*args, **kwargs)
        if "initial" in kwargs:
            self.initialize_time_window_fields(
                kwargs["initial"].get("restricted_sms_times", []),
                "use_restricted_sms_times",
                "restricted_sms_times_json"
            )
            self.initialize_time_window_fields(
                kwargs["initial"].get("sms_conversation_times", []),
                "use_sms_conversation_times",
                "sms_conversation_times_json"
            )
        if settings.SMS_QUEUE_ENABLED and self._cchq_is_previewer:
            self.fields["sms_conversation_length"].required = True

    def _clean_dependent_field(self, bool_field, field):
        if self.cleaned_data.get(bool_field):
            value = self.cleaned_data.get(field, None)
            if not value:
                raise ValidationError(_("This field is required."))
            return value
        else:
            return None

    def clean_default_sms_response(self):
        return self._clean_dependent_field("use_default_sms_response", "default_sms_response")

    def clean_custom_case_username(self):
        if not self._cchq_is_previewer:
            return None
        return self._clean_dependent_field("use_custom_case_username", "custom_case_username")

    def clean_custom_message_count_threshold(self):
        if not self._cchq_is_previewer:
            return None
        value = self._clean_dependent_field("use_custom_message_count_threshold", "custom_message_count_threshold")
        if value is not None and value < 0:
            raise ValidationError(_("Please enter a positive number"))
        return value

    def clean_custom_chat_template(self):
        if not self._cchq_is_previewer:
            return None
        value = self._clean_dependent_field("use_custom_chat_template", "custom_chat_template")
        if value is not None and value not in settings.CUSTOM_CHAT_TEMPLATES:
            raise ValidationError(_("Unknown custom template identifier."))
        return value

    def _clean_time_window_json(self, field_name):
        try:
            time_window_json = json.loads(self.cleaned_data.get(field_name))
        except ValueError:
            raise ValidationError(_("An error has occurred. Please try again, and if the problem persists, please report an issue."))
        result = []
        for window in time_window_json:
            day = window.get("day")
            start_time = window.get("start_time")
            end_time = window.get("end_time")
            time_input_relationship = window.get("time_input_relationship")

            try:
                day = int(day)
                assert day >= -1 and day <= 6
            except (ValueError, AssertionError):
                raise ValidationError(_("Invalid day chosen."))

            if time_input_relationship == TIME_BEFORE:
                end_time = validate_time(end_time)
                result.append(DayTimeWindow(
                    day=day,
                    start_time=None,
                    end_time=end_time
                ))
            elif time_input_relationship == TIME_AFTER:
                start_time = validate_time(start_time)
                result.append(DayTimeWindow(
                    day=day,
                    start_time=start_time,
                    end_time=None
                ))
            else:
                start_time = validate_time(start_time)
                end_time = validate_time(end_time)
                result.append(DayTimeWindow(
                    day=day,
                    start_time=start_time,
                    end_time=end_time
                ))
                if start_time >= end_time:
                    raise ValidationError(_("End time must come after start time."))
        return result

    def clean_restricted_sms_times_json(self):
        if self.cleaned_data.get("use_restricted_sms_times", False):
            return self._clean_time_window_json("restricted_sms_times_json")
        else:
            return []

    def clean_sms_conversation_times_json(self):
        if self.cleaned_data.get("use_sms_conversation_times", False):
            return self._clean_time_window_json("sms_conversation_times_json")
        else:
            return []

    def clean_show_invalid_survey_responses_in_chat(self):
        value = self.cleaned_data.get("show_invalid_survey_responses_in_chat", False)
        if self.cleaned_data.get("filter_surveys_from_chat", False):
            return value
        else:
            return False

class ForwardingRuleForm(Form):
    forward_type = ChoiceField(choices=FORWARDING_CHOICES)
    keyword = CharField(required=False)
    backend_id = CharField()

    def clean_keyword(self):
        forward_type = self.cleaned_data.get("forward_type")
        keyword = self.cleaned_data.get("keyword", "").strip()
        if forward_type == FORWARD_BY_KEYWORD:
            if keyword == "":
                raise ValidationError(_("This field is required."))
            return keyword
        else:
            return None

class BackendForm(Form):
    _cchq_domain = None
    _cchq_backend_id = None
    name = CharField()
    give_other_domains_access = BooleanField(required=False)
    authorized_domains = CharField(required=False)
    reply_to_phone_number = CharField(required=False)

    def clean_name(self):
        value = self.cleaned_data.get("name")
        if value is not None:
            value = value.strip().upper()
        if value is None or value == "":
            raise ValidationError(_("This field is required."))
        if re.compile("\s").search(value) is not None:
            raise ValidationError(_("Name may not contain any spaces."))

        backend_classes = get_available_backends()
        if self._cchq_domain is None:
            # Ensure name is not duplicated among other global backends
            backend = SMSBackend.view(
                "sms/global_backends",
                classes=backend_classes,
                key=[value],
                include_docs=True,
                reduce=False
            ).one()
        else:
            # Ensure name is not duplicated among other backends owned by this domain
            backend = SMSBackend.view("sms/backend_by_owner_domain", classes=backend_classes, key=[self._cchq_domain, value], include_docs=True).one()
        if backend is not None and backend._id != self._cchq_backend_id:
            raise ValidationError(_("Name is already in use."))

        return value

    def clean_authorized_domains(self):
        if not self.cleaned_data.get("give_other_domains_access"):
            return []
        else:
            value = self.cleaned_data.get("authorized_domains")
            if value is None or value.strip() == "":
                return []
            else:
                return [domain.strip() for domain in value.split(",")]

    def clean_reply_to_phone_number(self):
        value = self.cleaned_data.get("reply_to_phone_number")
        if value is None:
            return None
        else:
            value = value.strip()
            if value == "":
                return None
            else:
                return value

class BackendMapForm(Form):
    catchall_backend_id = CharField(required=False)
    backend_map = RecordListField(input_name="backend_map")

    def clean_backend_map(self):
        cleaned_value = {}
        for record in self.cleaned_data.get("backend_map", []):
            prefix = record["prefix"].strip()
            try:
                prefix = int(prefix)
                assert prefix > 0
            except (ValueError, AssertionError):
                raise ValidationError(_("Please enter a positive number for the prefix."))
            prefix = str(prefix)
            if prefix in cleaned_value:
                raise ValidationError(_("Prefix is specified twice:") + prefix)
            cleaned_value[prefix] = record["backend_id"]
        return cleaned_value

    def clean_catchall_backend_id(self):
        value = self.cleaned_data.get("catchall_backend_id", None)
        if value == "":
            return None
        else:
            return value

class InitiateAddSMSBackendForm(Form):
    action = CharField(
        initial='new_backend',
        widget=forms.HiddenInput(),
    )
    backend_type = ChoiceField(
        required=False,
        label="Connection Type",
    )

    def __init__(self, is_superuser=False, *args, **kwargs):
        super(InitiateAddSMSBackendForm, self).__init__(*args, **kwargs)
        backend_classes = get_available_backends()
        backend_choices = []
        for name, klass in backend_classes.items():
            if is_superuser or name == "TelerivetBackend":
                try:
                    friendly_name = klass.get_generic_name()
                except NotImplementedError:
                    friendly_name = name
                backend_choices.append((name, friendly_name))
        self.fields['backend_type'].choices = backend_choices

        self.helper = FormHelper()
        self.helper.form_class = "form form-horizontal"
        self.helper.layout = crispy.Layout(
            BootstrapMultiField(
                _("Create Another Connection"),
                InlineField('action'),
                InlineField('backend_type'),
                StrictButton(
                    mark_safe('<i class="icon-plus"></i> %s' % "Add Another Gateway"),
                    css_class='btn-success',
                    type='submit',
                    style="margin-left:5px;"
                ),
            ),
        )

class SubscribeSMSForm(Form):
    stock_out_facilities = BooleanField(
        label=ugettext_lazy("Receive stockout facilities SMS alert"),
        required=False,
        help_text=ugettext_lazy("This will alert you with specific users/facilities that are stocked out of your commodities")
    )
    stock_out_commodities = BooleanField(
        label=ugettext_lazy("Receive stockout commodities SMS alert"),
        required=False,
        help_text=ugettext_lazy("This will alert you with specific commodities that are stocked out by your users/facilities")
    )
    stock_out_rates = BooleanField(
        label=ugettext_lazy("Receive stockout SMS alert"),
        required=False,
        help_text=ugettext_lazy("This will alert you with the percent of facilities that are stocked out of a specific commodity")
    )
    non_report = BooleanField(
        label=ugettext_lazy("Receive non-reporting SMS alert"),
        required=False,
        help_text=ugettext_lazy("This alert highlight users/facilities which have not submitted their CommTrack stock report.")
    )

    def save(self, commtrack_settings):
        alert_config = commtrack_settings.alert_config
        alert_config.stock_out_facilities = self.cleaned_data.get("stock_out_facilities", False)
        alert_config.stock_out_commodities = self.cleaned_data.get("stock_out_commodities", False)
        alert_config.stock_out_rates = self.cleaned_data.get("stock_out_rates", False)
        alert_config.non_report = self.cleaned_data.get("non_report", False)

        commtrack_settings.save()